Cannot get regular expression to return true in String.matches()

Hi,
My String that I'm attempting to match a regular expression against is: value=='ORIG')
My regular expression is: value=='ORIG'\\) The double backslashes are included as a delimiter for ')' which is a regular expression special character
However, when I call the String.matches() method for this regular expression it returns false. Where am I going wrong?
Thanks.

The string doesn't contain what you think it contains, or you made a mistake in your implementation.
public class Bar {
   public static void main(final String... args) {
      final String s = "value=='ORIG')";
      System.out.println(s.matches("value=='ORIG'\\)")); // Prints "true"
}

Similar Messages

  • Match Regular Expression not returning submatches.

    I am having an issue with Match Regular Expression not returning the appropriate number of submatches.  My string is as follows:
    DATAM    995000    1.75    0.007    -67.47    24.493    99.072
    The spaces are tabs and the length is not fixed so simple string manipulation is out of the question.  The regular expression I was trying is as follows:
    (?<=\t)[0-9\.\-]*(?=(\t|$))
    It successfully returns Whole Match as the first number but no submatches are returned.  I've tried simpler expressions which work in Matlab and EditPad Pro such as [0-9.-]* but never got the same answer in Labview.
    What is going on?

    Here is an image of the VI.  The top portion is the input from our Licor 7000.  The bottom portion is the bit of code I'm having problems with.
    Attachments:
    matchregularexpression.jpg ‏336 KB

  • How to specify ");" as a regular expression in split method of String class

    How to specify ");" as a regular expression in split method of String class using delimeters?

    Sorry, you can't specify that by using delimiters. Mostly because this requirement makes no sense.
    Do you rather need "\\);"?

  • Cannot get Microsoft Express to work

    I have an e-mail account through the school that I go to. It is through Microsoft Express, but for some reason I cannot get that account to sync with my phone. It is claiming that the phone will not sync with the exchange. I have tried to up load while plugged into my computer with iTunes on (I have 9.2) and it still will not work!! ANy suggestions??

    yerbrother, Welcome to the discussion area!
    Usually you do not need to pay for this type of service. They are charging you per month for something that is done easily with a router.
    But I don't know anything about EarthLink broadband. If they require some type of special software to connect, it will not work with the AirPort Express (AX).

  • Cannot get Airport Express to join AT&T U-Verse (2Wire) for printing

    I just switched to AT&T U-Verse and now cannot get my Airport Express to join the network to provide wireless printing.  When I go through Airport Utility to configure the Airport to join an existing network to provide wireless printing it initally states setting change success and begins a restart process from which it never is found on the network again.  I contacted Apple Care who was very thourough in running various tests and settings and even checking AT&T 2-Wire network settings.  They even replaced my airport (which was 3 years old but covered under the Apple Care I purchased with my new iMac - very cool).  However, new Airport Express was still not able to join the network.  After another hour of working with Apple Care with the new Express the expert advised the issue must be with AT&T 2-Wire security settings.  I contacted AT&T U-Verse internet support and was advised they charge by the hour for network support and there is no guarantee it will be resolved.
    Anyone have this issue?

    Just found solution from another post from Mark:
    I had the same problem... couldn't get the AE to join the network. Here is how I got it to work. Go to the 2Wire config page in safari. For me it's <http://192.168.1.254> Go to settings tab. Go to LAN tab. Go to wireless heading. Under "Security", change "Authentication Type" to "WPA2-PSK (AES)". After the 3800HGV-B reboots, use Airport utility to configure the AE to join the wireless network. I have no idea why, but it works. The light is solid green and I can play Airtunes through my antique AE using iTunes or iPhone. Hope it works for you as well. Mark

  • OR ('|') in regular expressions (e.g. split a String into lines)

    Which match gets used when you use OR ('|') to specify multiple possible matches in a regex, and there are multiple matches among the supplied patterns? The first one (in the order written) which matches? Or the one which matches the most characters?
    To make this concrete, suppose that you want to split a String into lines, where the line delimiters are the same as the [line terminators used by Java regex|http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html#lt] :
         A newline (line feed) character ('\n'),
         A carriage-return character followed immediately by a newline character ("\r\n"),
         A standalone carriage-return character ('\r'),
         A next-line character ('\u0085'),
         A line-separator character ('\u2028'), or
         A paragraph-separator character ('\u2029)
    This problem has [been considered before|http://forums.sun.com/thread.jspa?forumID=4&threadID=464846] .
    If we ignore the idiotic microsoft two char \r\n sequence, then no problem; the Java code would be:
    String[] lines = s.split("[\\n\\r\\u0085\\u2028\\u2029]");How do we add support for \r\n? If we try
    String[] lines = s.split("[\\n\\r\\u0085\\u2028\\u2029]|\\r\\n");which pattern of the compound (OR) regex gets used if both match? The
    [\\n\\r\\u0085\\u2028\\u2029]or the
    \\r\\n?
    For instance, if the above code is called when
    s = "a\r\nb";and if the first pattern
    [\\n\\r\\u0085\\u2028\\u2029]is used for the match when the \r is encountered, then the tokens will be
    "a", "", "b"
    because there is an empty String between the \r and following \n. On the other hand, if the rule is use the pattern which matches the most characters, then the
    \\r\\n
    pattern will match that entire \r\n and the tokens will be
    "a", "b"
    which is what you want.
    On my particular box, using jdk 1.6.0_17, if I run this code
    String s = "a\r\nb";
    String[] lines = s.split("[\\n\\r\\u0085\\u2028\\u2029]|\\r\\n");
    System.out.print(lines.length + " lines: ");
    for (String line : lines) System.out.print(" \"" + line + "\"");
    System.out.println();
    if (true) return;the answer that I get is
    3 lines:  "a" "" "b"So it seems like the first listed pattern is used, if it matches.
    Therefore, to get the desired behavior, it seems like I should use
    "\\r\\n|[\\n\\r\\u0085\\u2028\\u2029]"instead as the pattern, since that will ensure that the 2 char sequence is first tried for matches. Indeed, if change the above code to use this pattern, it generates the desired output
    2 lines:  "a" "b"But what has me worried is that I cannot find any documentation concerning this "first pattern of an OR" rule. This means that maybe the Java regex engine could change in the future, which is worrisome.
    The only bulletproof way that I know of to do line splitting is the complicated regex
    "(?:(?<=\\r)\\n)" + "|" + "(?:\\r(?!\\n))" + "|" + "(?:\\r\\n)" + "|" + "\\u0085" + "|" + "\\u2028" + "|" + "\\u2029"Here, I use negative lookbehind and lookahead in the first two patterns to guarantee that they never match on the end or start of a \r\n, but only on isolated \n and \r chars. Thus, no matter which order the patterns above are applied by the regex engine, it will work correctly. I also used non-capturing groups
    (?:X)
    to avoid memory wastage (since I am only interested in grouping, and not capturing).
    Is the above complicated regex the only reliable way to do line splitting?

    bbatman wrote:
    Which match gets used when you use OR ('|') to specify multiple possible matches in a regex, and there are multiple matches among the supplied patterns? The first one (in the order written) which matches? Or the one which matches the most characters?
    The longest match wins, normally. Except for alternation (or) as can be read from the innocent sentence
    The Pattern engine performs traditional NFA-based matching with ordered alternation as occurs in Perl 5.
    in the javadocs. More information can be found in Friedl's book, the relevant page of which google books shows at
    [http://books.google.de/books?id=GX3w_18-JegC&pg=PA175&lpg=PA175&dq=regular+expression+%22ordered+alternation%22&source=bl&ots=PHqgNmlnM-&sig=OcDjANZKl0VpJY0igVxkQ3LXplg&hl=de&ei=Dcg7S43NIcSi_AbX-83EDQ&sa=X&oi=book_result&ct=result&resnum=1&ved=0CA0Q6AEwAA#v=onepage&q=&f=false|http://books.google.de/books?id=GX3w_18-JegC&pg=PA175&lpg=PA175&dq=regular+expression+%22ordered+alternation%22&source=bl&ots=PHqgNmlnM-&sig=OcDjANZKl0VpJY0igVxkQ3LXplg&hl=de&ei=Dcg7S43NIcSi_AbX-83EDQ&sa=X&oi=book_result&ct=result&resnum=1&ved=0CA0Q6AEwAA#v=onepage&q=&f=false]
    If this link does not survive, search google for
    regular expression "ordered alternation"
    My first hit went right into Friedl's book.
    Harald.

  • Regular Expression Character Sets with Pattern and Matcher

    Hi,
    I am a little bit confused about a regular expressions I am writing, it works in other languages but not in Java.
    The regular expressions is to match LaTeX commands from a file, and is as follows:
    \\begin{command}([.|\n\r\s]*)\\end{command}
    This does not work in Java but does in PHP, C, etc...
    The part that is strange is the . character. If placed as .* it works but if placed as [.]* it doesnt. Does this mean that . cannot be placed in a character range in Java?
    Any help very much appreciated.
    Kind Regards
    Paul Bain

    In PHP it seems that the "." still works as a all character operator inside character classes.
    The regular expression posted did not work, but it does if I do:
    \\begin{command}((.|[\n\r\s])*)?\\end{command}
    Basically what I'm trying to match is a block of LaTeX, so the \\begin{command} and \\end{command} in LaTeX, not regex, although the \\ is a single one in LaTeX. I basically want to match any block which starts with one of those and ends in the end command. so really the regular expression that counts is the bit in the middle, ((.|[\n\r\s])*)?
    Am I right it saying that the "?" will prevent the engine matching the first and last \\bein and \\end in the following example:
    \\begin{command}
    some stuff
    \\end{command}
    \\begin{command}
    some stuff
    \\end{command}

  • A regular expression to detect a blank string...

    Anyone know how to write a regular expression that will detect a blank string?
    I.e., in a webservice xsd I'm adding a restriction to stop the user specifying a blank string for an element in the webservice operation call.
    But I can't figure out a regular expression that will detect an entirely blank string but that will on the other hand allow the string to contain blank spaces in the text.
    So the restriction should not allow "" or " " to be specified but will allow "Joe Bloggs" to be specified.
    I tried [^ ]* but this wont allow "Joe Bloggs" to pass.
    Any ideas?
    Thanks,
    Ruairi.

    Hi ruairiw,
    there is a shortcut for the set of whitespace chars in Java. It is the Expression *\s* which is equal to *[ \t\n\f\r\u000b]*.
    With this expression you can test whether a String consists only of whitespace chars.
    Expamle:
    String regex = "\\s*"; // the slash needs to be escaped
    // same as String regex = "[ \t\n\f\r\u000b]";
    System.out.println("".matches(regex)); // true
    System.out.println("   ".matches(regex)); // true
    System.out.println("  \r\n\t ".matches(regex)); // true
    System.out.println("\n\nTom".matches(regex)); // false
    System.out.println("   Tom Smith".matches(regex)); // falseBesh Wishes
    esprimo

  • [Regular Expressions] Saving a variable number of matches

    I'm stuck with the following problem and I don't seem to be able to solve without lots of ifs and else's.
    I've got a program that you can pass patterns as parameters to. The program receives patterns as one single string.
    The string could look like this:
    a:i:foo r::bar t:ei:bark
    or like this:
    a:i:foo
    What I'm hinting at is that the string comprises of several parts of the same structure. Each structure can be matched and saved with:
    ([art]:[ei]{0,2}:.*)
    Now I want my regular expression able to match all the occurences without checking the string containing the pattern for something that could indicate the number of structures inside it. The following does not seem to work:
    ([art]:[ei]{0,2}:.*)+
    So now I'm looking for something that would match one or more occurence of the structure and save it for future use.
    I'd be really happy if someone could help me out here
    Last edited by n0stradamus (2012-05-03 20:27:02)

    Procyon wrote:
    --> echo "a:i:foo r::bar t:ei:bark" | sed 's/\([art]:[ei]\{0,2\}:[^ ]*\)/1/'
    1 r::bar t:ei:bark
    --> echo "a:i:foo r::bar t:ei:bark" | sed 's/\([art]:[ei]\{0,2\}:[^ ]*\)/1/g'
    1 1 1
    If [^ ]* is not usable (spaces are allowed arbitrarily), you need a non-greedy .* and non-consuming look-ahead of " [art]:"
    In python's re module, this is .*?(?=( [art]:|$))
    >>> import re
    >>> m=re.findall("([art]:[ei]{0,2}:.*?(?=( [art]:|$)))","a:i:foo r::bar t:ei:bark")
    >>> print(m)
    [('a:i:foo', ' r:'), ('r::bar', ' t:'), ('t:ei:bark', '')]
    Exactly what I was looking for! I didn't know that you could specify .* to stop at a certain sequence of characters.
    Could you please point me to some materials where I can read up on the topic?
    Back to the regex: It works finde in Python, but sadly that is not the language I'm using
    The program I need this for is written in C and until now the regex functions from glibc worked fine for me.
    Have I missed a function similar to re.findall in glibc?

  • Using Regular Expressions to replace Quotes in Strings

    I am writing a program that generates Java files and there are Strings that are used that contain Quotes. I want to use regular expressions to replace " with \" when it is written to the file. The code I was trying to use was:
    String temp = "\"Hello\" i am a \"variable\"";
    temp = temp.replaceAll("\"","\\\\\"");
    however, this does not work and when i print out the code to the file the resulting code appears as:
    String someVar = ""Hello" i am a "variable"";
    and not as:
    String someVar = "\"Hello\" i am a \"variable\"";
    I am assumming my regular expression is wrong. If it is, could someone explain to me how to fix it so that it will work?
    Thanks in advance.

    Thanks, appearently I'm just doing something weird that I just need to look at a little bit harder.

  • Unique regular expression to check if a string contains letters and numbers

    Hi all,
    How can I verify if a string contains numbers AND letters using a regular expression only?
    I can do that with using 3 different expressions ([0-9],[a-z],[A-Z]) but is there a unique regular expression to do that?
    Thanks all

    Darin.K wrote:
    Missed the requirements:
    single regex:
    ^([[:alpha:]]+[[:digit:]]+|[[:digit:]]+[[:alpha:]])[[:alnum:]]*$
    You either have 1 or more digits followed by 1 or more letters or 1 or more letters followed by 1 or more digits. Once that is out of the way, the rest of the string must be all alphanumerics.  The ^ and $ make sure the whole string is included in the match.
    (I have not tested this at all, just typed it up hopefully I got all the brackets in the right place).
    I think you just made my point.  TWICE.  While the lex class would be much more readable as a ring.... I know all my brackets are in the correct places and don't need to hope.
    Jeff

  • Cannot get Airport express to recognize on Vista PC

    Hi,
    I purchased the AirPort Express to play music off my Sounddock Portable in my Kitchen from a wireless signal off my router thats connected to a modem connected to my PC. I have a Linksys WRT150N Wireless Router that everyone in my house uses to access the internet. The modem is hooked up to the router in the computer room thats hooked directly to the Windows Vista PC. I am downstairs with an iMac, and also have a Macbook in the livingroom that transmits wireless internet just fine off this router.
    I first setup the Airport utility on the PC that the modem is connected to. Then I plugged in the Airport express and it turned green first, then flashed the blinking amber from then on. I opened up Airport Utility and it didn't read anything but prompted "A newer version (5.2.1) is available" so I click "Update" and it just disappears the prompt, and nothing downloads?
    I do a google search, find the 6.3 i believe it was, firmware update for windows.. try downloading that and I get an error when trying to set it up.. so apparently, I can't update this Airport Utility, and can't read the Airport Express.
    Just for curiousity, I brought the Airport Express downstairs, and plugged it into the wall and get the blinking amber. I installed the Airport Utility software to the iMac. It didn't pick it up on that, but also prompted an update needed. So my faithful Mac is able to update the software and then boom, it can recognize it. I didn't go into any setup with it due to the fact that I just had the airport express hooked up to the wall with no ethernet cable (as I want to use the airport express wirelessly). I don't understand how it was blinking amber but my iMac could still at least go into the next screen.
    I did try opening up my routers settings to see if anything was blocked. I saw in the security that MAC address filtering was disabled, so i enabled it and added the "Airport ID" MAC Address on the Airport Express in the list to allow to connect to, just to see if that would help, but it didnt.
    What I need is to get this to work as I spent $100 assuming it would pick up my wireless signal as do my other apple products, and so my family could enjoy music from the iTunes on my PC to the Sounddock in the kitchen. I was hoping it would be plug and play like my iMac and Macbook were. Please help as I would prefer to not return this item and just get it working =P

    Make sure you have the "latest" Airport Admin version of the SW for your PC.
    Secondly, just plug the PC directly into the Ethernet port on the Airport. (You probably need a Xover cable). It's been awhile since I've had to do this. So, double check the manual. Worst case, you can "reset" the Airport back to its defaults... Then update it from there.
    Dave

  • Cannot get Airport Express to join my AT&T 2wire router

    I folled the steps to connect my Airport express to an exiwsting wireless network. The System reboots then goes into flashing Amber state. The Router sees the device but it is not active. Any suggestions on what I need to do to get this attached to my network? I would like to use it to stream I-tunes music to my sterio in the other room. Thanks

    Just found solution from another post from Mark:
    I had the same problem... couldn't get the AE to join the network. Here is how I got it to work. Go to the 2Wire config page in safari. For me it's <http://192.168.1.254> Go to settings tab. Go to LAN tab. Go to wireless heading. Under "Security", change "Authentication Type" to "WPA2-PSK (AES)". After the 3800HGV-B reboots, use Airport utility to configure the AE to join the wireless network. I have no idea why, but it works. The light is solid green and I can play Airtunes through my antique AE using iTunes or iPhone. Hope it works for you as well. Mark

  • HT4913 I cannot get my ipad or iphone to recognize itunes match that is set up on my Mac.  Same id and password so not sure what I am not doing correctly.  When I attempt to turn it on the devices they both respond that I am not subscribed but I am .....h

    My iphone and ipad will not recognize my itunes match subscription I set up through my mac with same id and password.  I have followed all steps but phone and ipad respond that I do not have a subscription.  help?

    I'm having the same issue on my iPad.  Signed up for iTunes Match on my computer and tried to enable it on my iPad using the same apple ID and password but no luck.  I hope they resolve it soon.

  • Regular Expression Escaped Digit "\d" Illegal Escape Character

    Hello,
    I'm trying to write a regular expression to determine if a String matches a date format that is defined as YYYYMMDD. For example, March 11, 2009 would be "20090311"
    For the time being I don't care if an invalid month or day is entered. I've attempted both of the following
    if (date.matches("(19|20)\d{4}")) {
      // warn the user
    }and
    if (java.util.regex.Pattern.matches("(19|20)\d{4}"), date)) {
      // warn the user
    }And both yield Illegal Escape Character compilation errors, for the "\d" part of the regular expression.
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html#sum
    Says that "\d" is the predefined digit character class. So at this point, I don't know what I'm doing wrong. I realize I could just define the character class myself, and use a pattern like "(19|20)[0-9]{4}", but I would like to know why "\d" isn't being recognized by the compiler.
    Thanks,
    Paul

    paulwooten wrote:
    Can someone give me an explanation of heuristics, as they might apply to SimpleDateFormat? Does this mean that if the format was similar the parser might figure it out? Say, if instead of "yyyyMMdd", it was "yyyyddMM", or "yyMMdd"?No. Since all of these are valid formats, there's no way for the parser to distinguish this.
    Or does this have to do with rejecting February 29, and other dates like that.That's the one. When setLenient(false) is called, then the 29th February is only accepted in leap years.
    It will also reject the 57th January when lenient is set to false (try parsing that with lenient=true, you'll be surprised).
    I've read some of the wikipedia article about heuristics, but I'm confused as to how it would apply to this example.Don't concentrate to much on the term heuristics. Just remember: lenient=true means that not-really-correct dates will be accepted, lenient=false means more strict checks.

Maybe you are looking for

  • Performance Issue - Fetching latest date from a507 table

    Hi All, I am fetching data from A507 table for material and batch combination. I want to fetch the latest record based on the value of field DATBI. I have written the code as follows. But in the select query its taking more time. I dont want to write

  • How do I get the 1121 card to read the switch and make it a 1 or 0 to count pulses?

    Hello, I am developing a test stand to test tires. We have LabView 7.1 and the SCXI chassis with an 1121 transducer card. I am trying to count the rate and total number of revolutions made by the tire. The signal is acquired from a 12V-proximity swit

  • Exception when loading Creator project in Netbeans 5.5 Visual Pack

    java.lang.IllegalArgumentException: Project XXXXX is not open and cannot be set as main.      at org.netbeans.modules.project.ui.OpenProjectList.setMainProject(OpenProjectList.java:415)      at org.netbeans.modules.project.ui.actions.OpenProject.acti

  • Restoring Original Track Info?

    I know how to change the Genre/Grouping info for a track, but how would I go about restoring the original Genre per i-Tunes for an individual track? Is there something similar to the "get album artwork" or "get track name" options? Thanks, -b-

  • Account Assign Category in Req. Class

    Hi experts, Can anyone please let me know about the Account Assignment Category in Requirement Class(TC:OVZG)? What its control? My client bus process is 3rd party MTO what acct assign cat is suit to this process? let me explain an example...... 1. I