How to use regex to identify a "/".

Hi
I am trying to use the regular expressions package to distinguish between an XML start tag and an XML end tag (i.e. <tag> and </tag>). I am trying to do this by using the pretty much the following:
Pattern myPattern = Pattern.compile("/");
Matcher myMatcher = myPattern.matcher(myFile);
I know my java syntax is correct because it finds other regexes perfectly but for some reason it cant find a single slash.
if i replace occurences of the single slash in the myFile with double slashes the pattern matcher picks them up using the above pattern.
Why is this?
PS I know there are loads of APIs out there for playing with xml and i could use them but i was just messing around trying to do it myself. My question is about why the regex doesnt work
Many thanks

I guess this depends on the conent you're using in your file, and how you're using the matcher afterwards. For example, I just did this quick test?
import java.util.regex.*;
public class Test {
  public static void main(String [] args) {
    Pattern pattern = Pattern.compile("/");
    String sample = "/";
    Matcher matcher = pattern.matcher(sample);
    System.out.println(matcher.matches());
}And the output was true. However, if I change sample to have more than just a / in it, it doesn't work anymore. I would have to change the pattern to ".\*/.\*".
- Adam
Edited by: guitar_man_F on Sep 14, 2007 11:13 AM

Similar Messages

  • How to Use Regex Options in CS2 [JS] - Reg.

    Dear All,
    Hai, I have doubt about the Regex options using in CS2 - Script.
    Problem :
    filename = "FTR0123a.indd";
    k = Regex.match(filename,"(^FTR)(\d+)([A-Z*])\.(indd|indt))
    if k.match = success
    k1 = "."
    k2 = $1 [ Stored in First Value only]
    k3 = $2 [ Stored in Second Value only]
    Here I got the answers from VB.NET using Regex options. But I can't use the Same condition in Javascript.
    Please any one can give the solutions about the problem.
    Thanks & Regards
    T.R.Harihara SudhaN

    The correct format is
    filename = "FTR0123a.indd";
    k = filename.match (/^(FTR)(\d+)([A-Za-z]*)\.(indd|indt)/);
    This gives a five-element array, which you can see when you try this in the ESTK.
    Peter

  • How to use regex NEGATION with a (word) ?

    Hi all.
    How can I negate a given word ?
    For example:
    For the text "I love dogs but I hate cats" I want to write a regex that says: "Look for the word (dogs), followed by the word (cats) and allow any caracters between them, EXCEPT the word (hate)".
    So the regex would match for "I love dogs and, off course, also love cats", but would not match for "I love dogs but I hate, for sure, cats".
    Thanks in advance
    Fernando.

    Rather than looking for something that IS NOT there, look for something that is there and invert your response. The following string matches "...dog...hate...cat"
    REGEX PATTERN ".*dog.*hate.*cat$"

  • SAP IDM : Using regex for password

    Hi experts,
    I need your help about regex.
    We are trying to use this to be sure that password set in Web inteface by users are correct according to the company policies :
    - The first character cannot be a number
    - The three first characters cannot be the same
    We finally found the following expression to test what we want (reponse is "true" when one of the policies is ok) :
    (.)(1)|(d)
    But IDM never accept any password with that expression.
    So my questions are :
    1) Does IDM need a special regex language or is it the same than PERL language for example?
    2) Does anybody know how to use regex in our policies case?
    Thanks a lot for your response.
    Regards.
    Jérémy.

    Thanks a lot for your answers.
    Actually, i am already doing my test on another attribut which is not encrypted. but yeah its a good point to know about the encryption.
    I also tried to use evaluators on internet and my expression looks good if i want to catch cases that i dont want in my password...
    as a reminder : (.)(\1)|(\d)
    So if i write :
    "1password"   >> result : true
    "password"     >> result : false
    "pppassword" >> result : true
    "password01" >> result : false
    "passwooord" >> result : false
    but finally if i put that expression in the field "regex" of my attribut, IDM never let me save my new password because it's not a "correct value".
    So im disapointed because i don't how to solve it in IDM but i feel like i found the good expression...
    Any another idea?
    Regards
    Jeremy

  • How to use the "identify" feature in new 6.3.1 airport utility?

    how to use the "identify" feature in new 6.3.1 airport utility?
    so you can find the basestations in larger networks?

    There is a workaround, which is to use Airport Utility 5.6.
    I can confirm that 5.6 will run on 10.8.4 Mountain Lion, it will recognize the new 2013 Airport Extreme Base Station (A1521) running firmware 7.7.1, and it will give you access to view the device's Log & Statistics, DHCP Clients, and Profiles.
    Four caveats:
    1) The easiest way to install it is to download the app itself, not an installer or through the App Store. There is a page here where you can download the app: http://coreyjmahler.com/2013/03/08/airport-utility-5-6-on-os-x-v10-8-mountain-li on/ This way, you still have both versions, Airport Utility 6.x.x and 5.6.
    2) When you launch 5.6, you'll get a message saying a newer version is available and asking if you want to update. Click Cancel to proceed into the utility.
    3) When you click the Manual Setup button in 5.6, you'll get a warning dialog that "This version of AirPort Utility doesn't support this AirPort wireless device and might improperly configure the device if you continue to use it. Check www.apple.com/support/airport for the latest version of AirPort Utility." You can click Continue to get into the utility without issue.
    4) You should probably only use 5.6 to view the additional status details. I have not tried to modify and save any AEBS settings using 5.6. There are other discussions here in the forums indicating that attempting to save settings via 5.6 that are no longer available in 6.3.1 will not actually save the settings to the AEBS even if both utilities indicate that the settings are changed. See https://discussions.apple.com/message/22677993#22677993
    So, even though you can't use it to modify settings no longer available in Airport Utility 6.3.1, using Airport Utility 5.6 to view DHCP clients, Logs and Statistics is very useful for troubleshooting network issues.
    PS - There are two ways to get to the DHCP Clients list, neither of which is obvious The first is to go to the Airport pane -> Summary tab and click on the "Wireless Clients:" label in the Summary display. All of the labels from "Wireless Mode:" down on the Summary display operate as links to view/edit the corresponding info/settings, which is also not obvious at first glance. Also not obvious, clicking on "Wireless Clients:" actually brings up a new pane with three tabs: Logs, Wireless Clients, and DHCP Clients. You can also get to the same pane by going to the Advanced pane and clicking on the Logs and Statistics button.
    I hope this is helpful information. Took me a while to find out how to do this.

  • How can i assign an identifier to a movieclip using AS2 ???

    Hey guys, i'm using the scrolling pane component in my
    project. i used to enter in the content path, the identifier of the
    movieclip which i set through the library. But now i wanna give it
    a movie clip that i've created in my code...so how can i assign an
    identifier to a movieclip using AS2 so that i can use it with my
    componenets ???? THANX

    I'm trying to make a script that goes through a folder recursively, checks for every folder if it's name is "template", and if so it changes the icon of that folder to an icon
    I chose.
    I searched for an answer here, and I've only managed to find a way to assign an icon to a shortcut, but not to an existing file.
    Thanks in advance (:

  • How To Color a Text string using Regex (java.util.regex)

    Hello,
    How can I color a text string using regex class in 1.4?

    Yes, did you notice it said something about incredibly vague functionality?
    Let me break it down for you
    > How can I color a text string
    Strings do not have color... You can color a component (a label, a button), but you can't color a string
    > using regex class in 1.4?
    Using a regular expression? How would a regular exression color anything? Do you have embedded color codes? Are you searhing a string for some secret word?
    What are you talking about?

  • My iPhone 4 Bluetooth, using ios7, cannot identify any other bluetooth device (even other apple products). Says device not supported. How to solve this problem?

    My iPhone 4 Bluetooth, using ios7, cannot identify any other bluetooth device (even other apple products). Says device not supported. How to solve this problem?

    Supported Bluetooth Profiles
    It is not supposed to detect other Apple products via Bluetooth.

  • Firefox crashed before I could load my previous session - how may I restore it? I have backed up relevant session files, but have no idea how to use them.

    I was using Firefox shortly before deciding to restore my previous session (100+ tabs!), but the browser froze and went blank with the "Not Responding" label on top. This happened to me before, and I decided to just quit the session. I knew that I would lose the session I wanted, but I backed up the important session files found in the Mozilla directory (or at least whatever has "session" and "restore" in its name) while the browser was stuck (before quitting).
    What I'd like to understand is HOW TO USE these files to get my session back. I've tried replacing the session files with the back-up copies to no avail. Once long ago I managed to recover a session successfully, but with Firefox constantly changing, I may have lost touch with this.
    I use Firefox 34 and Windows 8.1, but I'll need others' help in identifying the session backup/restore files I need to use from the ones I backed up.
    I believe that the "recovery.bak" is vital, because it contains the tab/page names I was viewing.
    I would greatly appreciate whoever would help me in this, especially if they can teach me the proper methods to follow if this ever happens again (which most likely will!)

    You can look at this post in this MozillaZine forum thread about inspecting a sessionstore file and possibly extract URLs.
    *http://forums.mozillazine.org/viewtopic.php?f=38&p=12098147&start=60#p12098147
    You can open the Browser Console (Firefox/Tools > Web Developer).
    Paste the JavaScript code in the command line and press the Enter key to run the code.
    *Toggle the devtools.chrome.enabled pref on the <b>about:config</b> page to true to enable the command line
    *https://developer.mozilla.org/Tools/Browser_Console#Browser_Console_command_line

  • How to use the separate symbol in the text field in the adobe form.

    Hi,experts,
    I don’t know how to use the separate symbol to make a paragraph separate into several lines correctly in the text field in the adobe form.
    Action:
    1. config the ADS successfully.
    2. create the adobe form with a mult-line textfield(binding the 'remark' context in the interface of the form) using sfp.
    3. create a WDA for invoke the form and transfer the 'remark' context data.
    I use the following codes to display the paragraph in the PDF document:
    CONCATENATE
    '1&#12289;aaaaaaaaaaa&#65307;'
    '2&#12289;bbbbbbbbb '
    '3&#12289;ccccccccccc'
    '4&#12289;ddddddddd'
    INTO remark .
    lo_nd_z_hr_php_payslip->set_attribute(
    EXPORTING
    name = `REMARK`
    value = remark ).
    But I found all the content aren't paragraph separate correctly in the text field in the adobe form when I run the WDA.
    Could you please give me some hints to make the paragraph separate correctly in PDF document? Thanks a lot in advance!
    My email is : [email protected]
    Best regards,
    Tao
    Edited by: wang tao on Apr 8, 2008 1:58 AM

    Hi,
    If it is just a one word value then you could use this in the exist event;
    this.rawValue    
    = util.printx(">?<*",this.rawValue);
    This changes the first character (represented by the ?) to uppercase (represented by the >) and all trailing characters (represented by the *) to lowercase (represented by the <).
    If you wanted something more general ... if they could also enter a middle name then you could call a function like;
    function        toTitleCase(textValue)
      return  textValue.toLowerCase().replace(/\b[a-z]/g, function replacer(match) { return match.toUpperCase(); });
    This uses a regex to change all lowercase letters following a word boundary to uppercase.
    Bruce

  • How to use attributes in variable substitution???:(

    Hi all,
    Could you please help me out in how to use attributes in variable substitution....
    Regards,
    Sundar

    Hi,
    Use Adapter Specific Identifiers , instead of Variable Name substitution.
    Sender File adapter --> Adapter Specific Attributes --> Select File Name
    Reciver File Adapter -->Adapter Specific Attributes --> Select File Name
    In the mapping , use this code in an UDF to change the filename to what you want,
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String filename="YOURFILENAME";
    String rSourceFileName = conf.put(key,filename);
    Regards,
    Bhavesh

  • How to configure dhcp client identifier

    Hi Everybody,
    The DHCP client ID is an id that is unique for DHCP clients at least in the same subnet. Usually the client uses MAC-address as Client-Identifier in the DHCPDISCOVER message. The Client-Identifier may be different other than MAC-Address, For example a FQDN name, as per the RFC 2132 Ref, (code 61).+_
    Usaually, we use the following to bind the ip address based on MAC-address
    pntadm -r SUNWfiles -p /var/dhcp -A 10.42.32.86 -i '0:3:ba:a5:a9:93' -a 10.42.32.80
    At server side, I am using the following for specifying the FQDN name.
    pntadm -r SUNWfiles -p /var/dhcp -A 10.42.32.86 -i 'one.atr.com' -a 10.42.32.80
    and at client side, I am inserting the following entry in the /etc/default/dhcpagent file
    CLIENT_ID='one.atr.com'
    But this is not working. What I am doing wrong.
    +1. At the server side, then how to assign the ip addresses to the clients , if the Client-Identifier is FQDN name in the DHCPDISCOVER message other than MAC-Address.+
    +2. How to configure the client-identifier as FQDN name at client side.+
    Please help me,
    Thanks Inadvance,
    Mummaneni.

    Sandman,
    Here is an example of a router acting as a DHCP server. Please remember that you have to exclude IP addresses that you don't want to lease out.
    ip dhcp pool example
    import all
    network 192.168.1.0 255.255.255.0
    dns-server 1.2.3.4
    default-router 192.168.1.1
    ip dhcp excluded-address 192.168.1.1 192.168.1.149
    ip dhcp excluded-address 192.168.1.200 192.168.1.254
    HTH,
    Mark

  • How to use a Sybase table in Oracle SQL statement?

    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.

    user12088323 wrote:
    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.Any Oracle client connected to the Oracle database can access Sybase data through the <font style="background-color: #FFFFCC">Database Gateway for Sybase</font> (it requires an additional license) or the <font style="background-color: #FFFFCC">Database gateway for ODBC</font> (it's free).
    The Oracle client and the Oracle database can reside on different machines. The gateway accepts connections only from the Oracle database.
    A connection to the gateway is established through a database link when it is first used in an Oracle session. In this context, a connection refers to the connection between the Oracle database and the gateway. The connection remains established until the Oracle session ends. Another session or user can access the same database link and get a distinct connection to the gateway and Sybase database.
    Database links are active for the duration of a gateway session. If you want to close a database link during a session, you can do so with the ALTER SESSION statement.
    To access the Sybase server, you must create a <font style="background-color: #FFFFCC">database link</font>. A public database link is the most common of database links.
    SQL> CREATE PUBLIC DATABASE LINK dblink CONNECT TO
    2  "user" IDENTIFIED BY "password" USING 'tns_name_entry';
    --dblink is the complete database link name.
    --tns_name_entry specifies the Oracle Net connect descriptor specified in the tnsnames.ora file that identifies the gatewayAfter the database link is created you can verify the connection to the Sybase database, as follows:
    SQL> SELECT * FROM DUAL@dblink;
    Configuring Oracle Database Gateway for Sybase
    <font style="background-color: #FFFFCC">{message:id=10649126}</font>

  • How To Use Your Own Router with Out Loosing Verizon's FIOS Services

    How to use your own router with Verizon’s FIOS Service
    First, you need a basic understanding of how FIOS works but unfortunately there are two types of FIOS systems out there. All of the systems utilize a fiber optic cable to bring TV, phone and internet to your location over one optic cable. In addition these systems provide interactivity including widgets, remote DVR, movies on demand and so forth via an IP (Internet Protocol) signal.  Your STB (Set Tip Box) requires both a video and IP signal. The IP signal is necessary for all of the aforementioned interactivity.  The fiber cable terminates at the Optical Network Terminal or ONT for short.  The ONT converts the optics into a digital signal that can be utilized by ones equipment.  From the ONT your video, phone and internet are provided to the location.  This is where things can differ as the internet signal can be provided via a coaxial (MoCA or Multimedia over Coax Alliance) or RJ45 Cat5 (Ethernet) cable.  It is important to identify and understand the differences of these two setups.  In my case I have my internet entering via Ethernet cable, which in my humble opinion makes things a heck of a lot easier.
    How does one tell the difference? In most cases it’s rather simple; just look at the Verizon’s router WAN (Wide Area Network) Port.  Does it have a RJ45 (Ethernet) or Coax (TV cable Cord) going to it? If the router’s WAN port doesn’t have a coaxial connector then one will need to convert the MoCA signal into a usable Ethernet signal that routers understand. The easiest way is to use Verizon’s router as a bridge. In this method the Verizon’s router simply converts the signal and passes it along to your own router. The challenge is to try to maintain the interactivity that FIOS TV provides. Because of this one needs to supply the IP routed signal back to the FIOS router.  There are multiple methods for doing this and I would recommend investigates which one make the most sense.   
    In my particular case the IP signal was provided by Ethernet.  Again there are various ways of installing one’s own router. The hardest is to utilize Verizon’s router as a bridge.  This setup requires configuring Verizon’s router as a bridge and also creating a VLAN (Virtual Local Area Networks). In addition one needs to set up their own router so it will work with the various routing tables and networks. For me this is too complex for the average person and it can be difficult to trouble shoot if something goes wrong. Please consider that Verizon will not support utilizing third party routers.   
    The easier method is to request an Ethernet signal (if you don’t already have one) from their ONT.  I would highly recommend getting your hands on a NIM or Network Interface Module. This device is used to convert Ethernet to Coaxial so it can be fed back to your STBs.  These can be purchased online and Verizon technicians can be a valuable resource with these sorts of acquisition.  At the very least they can point you to the right direction.  Once you have a NIM the rest is rather simple.
    Log into the current Verizon Router.
    Located the router’s MAC address and copy it down.
    Go to the port forwarding section and copy down the Applied Rules. 
    Example:  
    Network Computer/Device: 192.168.1.100:63145
    Application & Ports Forward:  Application UDP Any -> 6347  
    Note: There may be up to three entries for each one of your Set Top Boxes.
    Look at your current device list, typically found on the home screen. Copy down your STB MAC and IP address.
    Example:
    IP-STB1
    Connection Type: Ethernet
    * IP Address: 192.168.1.100
    IP Address Allocation: DHCP
    *MAC Address:                07:73:fFe:ad:8b:3f
    * Things you will need to write down
    Go to the network section and look for the main Ethernet connection.  Select this and then select more setting, typically found at the bottom. Release the current lease.
    Remove the Verizon router
    Install your router
    Connect the NIM by plugging in an Ethernet from one of the routers LAN (Local Area Network) ports to your NIM. Then connect the coax cable, the same cable that was used by Verizon router.
    Set you DHCP routing IP pool to accommodate Verizon’s STB IP’s  (note their IP’s start at 192.168.1.100)
    Go to DHCP section and reserve the STB IP’s by inserting the IP’s and MAC addresses. This shall ensure that nothing else utilizes the same IPs as the STBs thereby preventing IP address conflict.  
    Add the port forwards from Step 5 above.
    Clone Verizon’s Mac Address utilizing the info from step 2
    Finish setting up the router in typical fashion.
    Unplug and re-plugin your STB’s and test functionality.  It’s best to try using a widget or Movie on demand function.
    Note: if the new router can net get an internet signal contact Verizon’s support and have them release the IP and reset the ONT.  
    EVERYTHING should be working at this point.

     3 Go to the port forwarding section and copy down the Applied Rules. 
    Example:  
    Network Computer/Device: 192.168.1.100:63145
    Application & Ports Forward:  Application UDP Any -> 6347  
    Note: There may be up to three entries for each one of your Set Top Boxes.G
    Your display obviously is not like mine as mine does not dosplay the port associated with the ip address
    whatever, the STB's start at 192.168.1.100 and icement by 1 for each
    the port addr's will be 63145 alo incrementing by 1
    there is 1 entry for each in my pf list
    however each ip addr also has a port entry starting at 35000 also incrementing by 1 for each ip addr
    For some unknow reason these are duplicated e.g I appear to have 11 entries exaactly the same for each stb and as the fios services rules have no action switc there is nowhere to delete the extraneous garbage.
    Why do you clone the mac addr??

  • Does anyone know how to use pages so you can export pdfs from the internet and automatically drag words from the document into the file name of the pdf (i.e., author, title of a scientific paper)

    Does anyone know how to use pages so you can export pdfs from the internet and automatically drag words from the document into the file name of the pdf (i.e., author, title of a scientific paper). For example, if I am downloading a paper by smith called "Surgery" that was published in 2002, it will automatically set the file name in the download to smith- surgery 2002. I have heard pages is smart enough to do this.
    thank you

    Pages can export only its own documents. They may be exported as PDF, MS Word, RTF or Text files.
    Pages can import (ie. Open a file as, or Insert a file into, a Pages document) documents in several formats, but won't rename the document as you describe. Documents that can be Opened (eg. Text, AppleWorks 6 WP, MS Word files) are converted to Pages documents, and retain their original names, with .pages replacing the original file extension. Files that can be Inserted (generally .jpg, .pdf and other image files) become part of the existing Pages file and lose their names.
    It may be possible, using AppleScript, to extract the text you want and to Save a Pages file using that text as the filename, but that would depend in part on being able to identify which text is wanted and which is not.
    How will the script determine where the author's name begins and where it ends?
    How will the script recognize the beginning and of the title, an decide how much of the title to use in the filename?
    How will the script recognize the year of publication?
    For papers published in a specific journal, with a strict format for placing each of these pieces on information, or containing the needed information as searchable meta data in the file, this might be possible. But it would require knowledge of the structure of these files, and would probably handle only papers published in a specific journal or set of journals.
    Outside my field of knowledge, but there are some talented scripters around here who might want to take a closer look.
    Best of luck.
    Regards,
    Barry

Maybe you are looking for

  • How do I find out the ID number for a Podcast?

    I want to link to a few different podcasts in itunes from my website . I have seen links that include a podcast ID number, such as ...viewPodcast?id=xxx, but I can not see where to find the ID number of the podcasts I want to link to. Has any done th

  • ALV CHECK CHANGED DATA WITH REUSE_ALV_GRID_DISPLAY

    HELLO  EVERY-ONE.     I have a question that how to check changed data in ALV. I know we can use CHECK_CHANGE_DATA Method in OO, and how to check it in REUSE_ALV_GRID_DISPLAY <b>without double click</b> ?

  • Correspondance can't be printed

    in fb03 menu, I go to environment/correspondance, it shows the correspondance type Z001, after I click continue, it says the official receipt was requested, but when I go to SP01, there is no spool generated, how to print this official receipt( corre

  • Dev 6.0 to 8iEE Connection on same NT Box

    Hi, Seems from what I have read it is a common problem to connect Dev 6.0 to 8i on same NT Box. Reckon we all need this process documented. I am currently unsuccessful in this task and so need some help. 1. Load NT with TCP/IP machine name "delly" 2.

  • Some visitors unable to access my iWeb site

    Need some help please! I have an iWeb site with a blog that some of my friends are having trouble accessing. I know that the Safari and Firefox users are not having any issues, but the strange part is that SOME of the IE users have trouble, but not a