Simple Regular Expression Question

Or ist it not so simple? Decide yourself:
If a random text (lets say "Nader") does not contain for example the string "Bush", then it shall match the pattern. But how would that pattern look like?
First I tried ^(Bush). But it doesn't work. Then I tried lots of other things and googling, with no success.
Any ideas for that simple thing?

Let me get this straight.
Text area A will have some text in it. Let's say the user supplies "Bush".
Right?
Text area B is allowed to contain any text in it except an exact match of what is in text area A.
Right?
if (B.getText().equals(A.getText())) { // or however you get the string from a TextArea
  // Uh-oh! They match!
}But it can't be that simple, else you woldn't have posted.
So what are you looking for?
Can A contain stuff that is to be interpreted as a regex? That is If A has "B.*sh" then B must not start with "B" and end with "sh"?
Will either or both of them be line-based? That is:
A:
Bush
Cheny
B:
Clinton
Bush
and no line from A must match any line from B?
Maybe I'm just dense, but I still don't really understand what you're looking for, or why you need regex since you seem to be just looking for an exact string match. Initially you said "contain", which suggests " .* Bush .* " but later you seem to be talking about exact matches.

Similar Messages

  • Regular Expressions - Questions to SME

    Ralph Benzinger presented an online meetup on the topic of Regular Expressions.  The presentation (slides only) can be found <a href="http://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/866072ca-0b01-0010-54b1-9c02a45ba8aa">here</a>
    Unfortunately the recording is not going to be available, but Ralph has been generous enough to agree to answer questions posted to this sticky thread.
    cheers,
    Marilyn

    Hello Peter,
    You're welcome!
    Alas, I was unable to locate the regex documentation on help.sap.com either.  In fact, I'm not even sure it has already been updated for 2004s.  I recommend that you use the online documentation within the system, e.g., from transactions SE38 or SE80.  Do an index search for "regex", and you'll be directed to REGEX, FIND and REGEX, REPLACE, both of which have extensive subsections on regexes.
    The class cx_sy_regex is an exception class that is thrown by FIND, REPLACE and cl_abap_regex in case of an invalid regex, such as ".\1" (there is no capture group that back reference \1 can refer to).  If the pattern is known statically, the syntax check will report this error, but for statements like "FIND REGEX pat IN text.", the actual pattern is only known at runtime.
    The cx_sy_matcher class (and its subclasses) similarly indicate some invalid states, for example trying to call "cl_abap_matcher->replace_found( )" when the matcher has no current match to replace (e.g., replace_found( ) called twice in a row).
    Please let me know if I can provide some additional information.
    Regards
    Ralph

  • A regular expression question

    I have a large body of text which I am breaking into individual words (as part of an experimental indexing project.)
    I can break the text into a list by making a paragraph break for every word space (a simple find and replace).
    But I want proper names to remain unbroken.
    So I am trying to write a regular expression script which will find every occurence of two contiguous words which each begin in a capital letter, and then to replace the space between the two words with an underscore.
    So Sigmund Freud becomes Sigmund_Freud.
    Does anyone know how I would write this script?
    Thanks!!!

    You don't need a script, you can do it in the interface:
    Find: (\u[-\w]+)\x{20}(?=\u[-\w]+)
    Change: $1_
    \u[-\w]+ stands for "upper-case letter followed by one or more of hyphen/word character"; here the first name.
    \x{20} stands for the space.
    followed by another \u[-\w]+, the last name. This one is in a lookahead, so the whole expression paraphrases as "find a word that starts with an upper-case letter followed by a space if it's followed by another word starting with an uc letter".
    Peter

  • Help: Regular Expression question??

    Hello,
    How can I extract the following content using Java Regular expression?
    <tr bgcolor="#333333">
         <td class="title" colspan="4" height="18"> <b>SUPER_1</b> - SUPER_2</td>
    </tr>
    <tr bgcolor="#333333">
         <td class="match-light" width="45" height="18"> </td>
         <td class="match-light" colspan="3" width="286" align="right">March 19 </td>
    </tr>
    <tr>
         <td colspan="4" height="1"></td>
    </tr>
    <tr bgcolor="#cfcfcf">
         <td width="45" height="18"> FT</td>
         <td width="118" align="right">SUPER_3</td>
         <td width="50" align="center"><a class="scorelink" target="details" onclick="showDetails();">999 - 888</a></td>
         <td width="118">SUPER_4</td>
    </tr>From the above contents, How can I define a regular expression for extract the "*SUPER_1*", "*SUPER_2*", "*March 19*", "*SUPER_3*", "*999*", "*888*" and "*SUPER_4*" ????
    Please help.
    Best regards,
    Eric

    Kayaman wrote:
    Why not use a better way than regex, like an actual HTML parser (or XML if you have it well-formed)? People seem to love parsing (or rather, asking help how to parse) HTML with regex for some unknown reason.Indeed.
    Read this (hilarious):
    http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

  • Help: Verify or Suggest a Simple Regular Expression

    I'm trying to do a mapping from a title to a file name portion of a URL. Thus the result needs to follow the rules as specified here:
    http://labs.apache.org/webarch/uri/rfc/rfc3986.html#unreserved
    I identified the following characters as legal: a-z / 0-9 / "-" / "." / "_" / "~"
    Everything else has to be converted to an underscore.
    I came up with the following expression:
    someString.replaceAll("[^a-zA-Z0-9-._~]", "_")Is that correct? I spent a lot of time trying to figure out regular expressions, but it seems like everyone (i.e. PHP, TextPad and now Java) has a slightly different version and to top it off, there not very good tutorials or explanations. I dread regular expressions!!!
    Can anyone help please?

    HoganWang wrote:
    Ur regular expression is right. The regular expression has simple and complex versions. If the replaceAll is frequently called, it is recommended to use Pattern to compile the regular expressions first.How does the expression know that the hypen isn't part of range? I guess the only way is that it is between alphabetical letters or numbers.
    In terms of efficiency. This is called once per page request i.e.
    somedomain.com/somecategory/title_title_title
    Well, I need to be able to translate title&title$title to title_title_title. It doesn't seem like a pre-compiling the regular expression will speed it up since between page requests, it won't remember fields or am I wrong?

  • Regular Expression Question

    Hi all,
    I am suffering in java regular expression, and I hope you guys can help me out. I want to use the String api ".matches" to find out any string pattern like "xxxx.xxxx" where xxx can be only english word(both upper and lower case). Actually I will use this kind of expression to represent the cross join SQL statement in my java class, like "tableA.name = tableB.name", where they should be english letter only. I tried to use MyString.matches("^[A-Z] + \\. + ^[A-Z]") in my java program, but seem it doesn't work. Can you guys figure out the right expression for me ?? Many thanks
    Transistor

    Thanks for your prompt response, I tried your code, however, it doesn't work out.
    I put your code like the following:
    if ( searchCriteria.getStringPair().getValue().trim().matches("[A-Za-z]+\\.[A-Za-z]+") {...some action }.
    Seems the java program never reach this expression.
    Kindly remind that I wan to expression anything like "xxxxx.xxxxx" where xxxx can be a word.
    Myriads of thanks
    Transistor

  • Regular Expression Question, Repetition Operators

    These are my success entries for a field;
    123456,
    123456,123456,
    123456,123456,123456,
    123456,123456,123456,123456,
    "," seperated 6 digits can be repeated unlimited times.
    I found on documentation this; "Repetition Operators; {m,}     Match at least m times" and for my need i tried this regular expression; "^[[[:digit:]]{6},]{1,}$", but didnt worked :(
    Any comments?
    Thank you very much :)
    Tonguc

    repeating exactly 6
    {6}
    repeating at least 1
    +
    repeating at least 6
    {6,}
    ok, your problem is [ instead of (                                                                                                                                                                                                                                                    

  • Regular Expression question I think

    My application is receiving HTML as a string and I'm trying to simplify it before displaying. The string could contain one or more substrings similar to this:
    <span style="cursor:pointer" onmouseout="hideTooltip()" onmouseover="createTooltip( this,'The quartile that your firm\'s value falls into.  Each quartile contains 25% of the values in the Peer Group. The 1st Quartile is always the best.  The 4th Quartile is always the worst.', ( findPosX( this ) - 150))">Quartile</span>The text will not be consistent and it may be in the string as many as 4 times. What I'd like to do is replaceAll so that I end up with
    <span>Quartile</span>Is there a way to do this with regular expression? I've tried replaceAll("<span .*>","<span>") But that takes out everything to the end of the String. I want it to stop at >.
    Any way?

    replaceAll("<span .*?>","<span>")

  • Regular expression question (should be an easy one...)

    i'm using java to build a parser. im getting an expression, which i split on a white-space.
    how can i build a regular-expression that will enable me to split only on unquoted space? example:
    for the expression:
    (X=33 AND Y=44) OR (Z="hello world" AND T=2)
    I will get the following values split:
    (X=33
    AND
    Y=34)
    OR
    (Z="hello world"
    AND
    T=2)
    and not:
    (Z="
    hello
    world"
    thank you very much!

    Instead of splitting on whitespace to get a list of tokens, use Matcher.find() to match the tokens themselves: import java.util.*;
    import java.util.regex.*;
    public class Test
      public static void main(String[] args) throws Exception
        String str = "(X=33 AND Y=44) OR (Z=\"hello world\" AND T=2)";
        List<String> tokens = new ArrayList<String>();
        Matcher m = Pattern.compile("[^\\s\"]+(?:\".*?\")?").matcher(str);
        while (m.find())
          tokens.add(m.group());
        System.out.println(tokens);
    }{code} The regex I used is based on the assumptions that there will be at most one run of quoted text per token, that it will always appear in the right hand side of an expression, and that the closing quote will always mark the end of the token.  If the rules are more complicated (as sabre150 suggested), a more complicated regex will be needed.  You might be better off doing the parsing the old-fashioned way, with out regexes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Regular Expressions Question

    I am using regular expressions to parse through a text file generated by a set of sensors attached to a SeaBird CTD profiler, what matter is that some lines use quotes as a special marker and some dont, but I need to treat both as the same data. Here is the example:
    SeaBird Datafile (just some part):
    "# name 0 = depS: depth, salt water [m]"
    "# name 1 = t068: temperature, IPTS-68 [deg C]"
    # name 2 = sal00: salinity, PSS-78 [PSU]
    "# name 3 = sigma-t00: density, sigma-t [kg/m^3]"
    "# name 4 = flS: fluorometer, sea tech"And I am using this regular expression to read this lines and save those names:
    private static final String ColumnName = "(^\"#|^# ) name (\\d)+ = ((.+)\"$|(.+)$)";There is a possiblity that the string either starts with "# and ends with ", or that it only starts with # and no special marker to the end. Can anyone enlighten me on the correct regex because the one I posted up there only works in the case of being surrounded by quotes. Thanks in advance!
    Christian A. Sueiras

    Try this: private static final String ColumnName = "^(\"?)# name (\\d+) = (.+)\\1$";{code} You match an optional quotation mark at the beginning, and capture it in group #1.  At the end, you match whatever was captured in group #1: either a quotation mark, or nothing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Validation on text item as Regular Expression Question(Repetition Operator)

    These are my success entries for a field;
    123456,
    123456,123456,
    123456,123456,123456,
    123456,123456,123456,123456,
    "," seperated 6 digits can be repeated unlimited times.
    I found on documentation this; "Repetition Operators; {m,}     Match at least m times" and for my need i tried this regular expression; "^[[[:digit:]]{6},]{1,}$", but didnt worked :(
    Any comments?
    Thank you very much :)
    Tonguc

    Your expression is a little incorrect because you can't use repetition operators within a bracket expression. How about something like this
    "^([[:digit:]]{6},)+$"
    Regards,
    Peter

  • Simple regular expression problem

    Hello,
    I need help with regular expressions. I have a situation when I need to get data from one table to another and I think my problem can be solved using REG EXP, but I don't know how to use them properly.
    I need to seperate varchar2 fileld whcih is basically number/number into 2 seperate number fields
    CREATE TABLE tst (CODE VARCHAR2(10));
    INSERT INTO tst VALUES('10/15');
    INSERT INTO tst VALUES('13/12');
    INSERT INTO tst VALUES('30');
    INSERT INTO tst VALUES('15');
    CREATE TABLE tst2 (po NUMBER, co NUMBER); I need to get code into co and po columns. I think result should look something like this, but:
    INSERT INTO tst2
    SELECT regexp_substr(CODE 'something here to get the number before /') AS po,
           regexpr_substr(CODE 'something here to get number after') AS co
    FROM tst;   Any help appreciated

    Hi Blu,
    Yes, I have tested with "0" in the figure (like 10/20 30/40). And it worked that time and then I replied. :) :)
    But Still it has a problem in pattern and rectified it below.
    Like :-
    SQL> select regexp_substr('10/40','[^/][0 9]',1,2) DD from dual;
    DD
    40
    But if I (The way you test) use a non zero value like 43 ; below query will not return 43.
    SQL> select regexp_substr('15/43','[^/][0 9]',1,2) DD from dual;
    DD
    My pattern has a slight mistake("-" missing between 0 and 9) and I changed and retested . Correct pattern - '[^/][0-9]' and now it will return 43..
    SQL> select regexp_substr('15/43','[^/][0-9]',1,2) dd from dual ;
    DD
    43this '[^/]+' pattern also works fine.
    Thank you for pointing out Blu; as I came to know lot more about patterns.
    Regards,
    Ashutosh

  • Quick regular expression question/help

    Can someone help me with two regular expressions I need. I could spend a while trying to figure it out myself, however times short and I really would like to get a fool proof optimal solution (my attempt would be buggy).
    Sample sentence
    The population, is projected to reach 200,000, or more (by 2020).[7] This is {dummy} text.
    The first regular expression
    I need all brackets and every thing between them to be removed from a sentence.
    Brackets such as: ( ), [ ] and { } .
    I.e. Given the above sentence the following would be returned:
    The population, is projected to reach 200,000, or more. This is text.
    The second regular expression
    If a word has a trailing comma character I need to add a whitespace between the word and the comma.
    I.e. Given the sentence returned from the first regular expression, this regex would return:
    The population *,* is projected to reach 200,000 *,* or more. This is text.
    Many thanks to anyonewho can help me with this!
    Edited by: Myles on Jan 18, 2008 8:12 AM

    http://java.sun.com/docs/books/tutorial/extra/regex/index.html
    http://www.regular-expressions.info

  • Quick regular expression question!

    If I have a String such as:
    "This is a sentence.[1] This is another."
    OR
    "This is a sentence.(1) This is another."
    I.e. A String has a full stop within it and a non alphanumeric character immediately after it (without whitespace between the full stop and the character)
    How can I insert a whitespace character between the full stop and the non alphanumeric character (such as a bracket in the above examples)?
    So the above Strings would be transformed into:
    "This is a sentence. [1] This is another."
    "This is a sentence. (1) This is another."
    Thanks

    If I understand what you're asking...
    str = str.replaceAll("\\.([^\\p{Alnum}\\s])", ". $1");
    "This is sentence.[1] This is another.(1) This is a third. [1] This is a fourth.& This is a fifth. This is the last."
    "This is sentence. [1] This is another. (1) This is a third. [1] This is a fourth. & This is a fifth. This is the last."For more info:
    http://java.sun.com/docs/books/tutorial/extra/regex/index.html
    http://www.regular-expressions.info/

  • Simple regular expression/perl/sed type question

    If I have a string like this:
    1. e4 c5 2. Nf3 Nc6 3. Bc4 e6 4. c3 Nge7 5. d4 d5
    and I want to put
    after ever third "word" (i.e., before 2., 3., 4., 5. ...)
    how do I do it?

    Find:
    s(d+.s)
    Replace:
    $1

Maybe you are looking for

  • Jabber for Window, phone mode, how to disable "use my computer for calls"

    We have a Citrix environment and only want to control the Cisco deskphone with Jabber for Windows in the phone mode. We use CUCM 8.6.2 and I have installed Jabber for Windows 9.7.0 and all works fine, I can control my deskphone, make and receive call

  • Filter a table view

    Hi All, In a compound layer with 2 table views, is it possible to filter only one of them? (if I apply the filter in Criteria Tab or Column formulla it applies to all the views, so I need to apply the filter after retriving the results) Thanks, Regar

  • Imac host doesn't see target computer

    Hello, I'm having difficulty copying files from the host computer to the target computer. The target computer is an Imac 700Mhz G3 and the host is a 400Mhz (DV?) G3. Both are running OS 10.3.9. The problem is that the target computer does not show up

  • How to get a cc copy of LR5 on my computer, not a trial?

    LR5 now appears in the 'your apps' section of my creative cloud panel, but I still need to use 'trial' every time I open lightroom...I never get a window asking me for my id or password like i did with photoshop... I signed up yesterday for the ps +

  • Xserve - Mirrored RAID Failed? Degraded? Confused...

    Hi, Can anyone shed some light on this situation please? Disk utility tells me one thing and Server Monitor tells me another. I have an X-Serve with 3 drives and a Mirrored RAID Set running 10.5.8. Server Monitor is showing a yellow status for disk 1