Basic question on this Regular Expression syntax

The below query returns the string before the first comma.
SQL> select regexp_substr('JACK,AND,JILL,WENT', '[^,]+' ) FROM DUAL;
REGE
JACKWhat does
[^,]do? Does it just mean, look for comma (,)
What does the plus sign in
'[^,]+'do?
These are not mentioned in the 10GR2 's SQL Reference for REGEXP_SUBSTR function, hence i am posting this in OTN.

Hi, Hoek,
hoek wrote:
Hi Pete,
They are documented:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_regexp.htm#sthref547
Metacharacter     Description
^     Anchor the expression to the start of a lineIt looks like you were in a hurry.
The ^ in
[^,]+is the non-matching character marker: "Matches any single character not in the list within the brackets"

Similar Messages

  • Question about match regular expression

    Colleagues,
    Very stupid question. I would like to get substring between "..." symbols. For example, string 02 July from Explosion occurred on "02 July", 2008.
    How to do this with single Match Regular Expression?
    For example such expression ".*" will give me "02 July":
    But I would like to get it without " symbols!
    I tried this "[~"]*" and this "[~"].*", then read this and this , and all without success... But I'm sure it should be possible. Can you help me?
    Andrey.
    PS
    This regular expression should give exactly the same output as following construction:

    I'm only using 7.0 now, but you can do this with Scan from String...
    %[^"]"%[^"]"%[^"]
    Message Edited by Phillip Brooks on 07-02-2008 02:47 PM
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness
    Attachments:
    NotPCRE.png ‏20 KB

  • FM9 SDL Authoring Assitant Regular Expression Syntax?

    I'm trying to trick SDL into identifying words that are not approved by STE.
    Under "Configure|Style and Linguistic Checks|User Defined Rules" the program allows regular expressions to create custom rules.
    I have all other options in the Utility unchecked.
    I am by no means a pro at regular expressions but was able to create a pretty solid command at http://regexlib.com/RETester.aspx.
    The idea is to create an expression that looks for any word other than those seperated by vertical bars.
    For the test text "this is not the way that should work. this is not the way that should work."
    \b(?:(?!should|not|way|this|is|that).)+
    returns: the work the work
    At that website, I can change the excluded words and it works every time. Change the test text, same thing, still works.
    Perfect! I ripped every approved word in STE into the formula and it (SDL) only returns words at the end of the sentence that are followed by a periods and question marks. So I added"\." to the exclusion list in the expression and it only found words next to question marks. I excluded question marks and now it finds nothing. I don't understand this as I wasn't aware that I had any criteria in the expression that dictates functionality only at the end of the sentence.
    I have an O'reilly book to refer to, if anyone can give me a shove in the right direction as to which set of rules to adhere to, I would appreciate it. Why did negative word matching have to be my introduction to this subject?

    I tried your expression in a couple of regex tools and it seems to parse as you wanted it to. I suspect that the SDL implementation doesn't follow the unix/linux standards. I haven't used the tool and the usage documentation is non-existant, except for the limited flash-based demo.
    From the SDL knowledgebase, it states that their regex filter uses the .NET regex flavour and I believe that the differences on this are explained in the "Mastering Regular Expressions" book.

  • Question sql and regular expressions

    I am trying to write a query where a like with a regular % wont work.
    select <cols>
    from <tab>
    where col2 starts with 'SOME CHARACTERS' The field can have 0 or more empty spaces before there are more characters. However, I know what those characters are. How do I do 0 or more characters?
    select mycols
    from myemptable
    where empname like 'JO%JO'There could be 0 or more empty spaces between JO and JO, but the next character is 'JO' . This is a general case. So it could be something else.
    so % won't work. since i could get back 'JO HA JO' which I dont want.

    Regular expressions where introduced with Unix in 1973.
    It shouldn't be difficult to find online resources.
    You seem to belong to the big class of users in this forum who doesn't know how to use the Internet, or find that to demanding.
    The solution can of course be found in 5 minutes, of 2 to start my database especially for you at almost midnight.
    with a as (select 'JO JO' col1 from dual
                  union
                   select 'JO    JO' col1 from dual
                   union
                  select 'JO HA JO' col1 from dual
                  union all
                  select 'JO  JO BLEH' from dual)
       select * from a where regexp_like(col1,'^JO( +)JO.*$')
    You find out what it means as exercise.
    Sybrand Bakker
    Senior Oracle DBA

  • A question about using regular expression

    Hi,
    This is a part of HTML file.
    <SPAN>how</span>
    <SPAN>are</span>
    <SPAN>you</span>
    I want to search string between each pair of <SPAN> , </SPAN> tags by using Regular Expression.
    For example:
    how
    are
    you
    If I use following method
    String regx="<SPAN>(.+)<SPAN>";
    Matcher m=Pattern.compile(regx).matcher(str);
    int currentLoc=0;
    while(currentLoc<str.length()){
        if(m.find(currentLoc))
        System.out.println(m.group(1));
        currentLoc=m.end();
    }The content between first <SPAN> and last </SPAN> will be searched.
    How to solve this problem?

    Use a non-greedy match:
    (?s)<SPAN>(.+?)<SPAN>(?s) makes the dot match the line terminator (same as setting the dot all option)

  • How this regular expression work in detail

    Who can tell me how does the following regular expression work step by step, thanks!
    string input = "PRIVATE11xxPRIVATE22xx123PRIVATE33";
    string pattern = @"(?<Pvt>PRIVATE)?(?(Pvt)(\d+)|([^\d]+))";
    string publicDocument = null, privateDocument = null;
    foreach (Match match in Regex.Matches(input, pattern))
    if (match.Groups[1].Success)
    privateDocument += match.Groups[1].Value + "\n";
    else
    publicDocument += match.Groups[2].Value + "\n";
    Console.WriteLine("Private Document:");
    Console.WriteLine(privateDocument);
    Console.WriteLine("Public Document:");
    Console.WriteLine(publicDocument);

    Hi Sincos,
    sure:
    Your regular expression has two main blocks:
    1. (?<Pvt>PRIVATE)?
    That means find a string PRIVATE with zero or one repetition. This is a named capture group with the name "Pvt" to access it later
    2. (?(Pvt)(\d+)|([^\d]+))
    That's a conditional Expression with a yes and no clause. So let's split this one up:
    The first part (Pvt) means whether the string "PRIVATE" was found or not.
    When it was found, this gets active: (\d+)
    When it was not found, this gets active: ([^\d]+)
    So let's look at those two:
    (\d+) means a numbered capture Group. So one or more numbers
    ([^\d]+) means any character that is not in [\d], so not a number, with one or more repetitions
    Ok. So your regex ends up with three groups:
    1 Group: Numbered Group for [\d+]
    2 Group: Numbered Group for [^\d+]
    3 Group: Named Group for the string "PRIVATE"
    Now let's look at your input string "PRIVATE11xxPRIVATE22xx123PRIVATE33"
    With that one you'll have four matches:
    1st match "PRIVATE11"
      1 Group: "11"
      2 Group: -
      3 Group (Pvt): "PRIVATE"
    2nd match "xxPRIVATE" (String private was not found, so [^\d+] is used (any character not a number))
      1 Group: -
      2 Group: "xxPRIVATE"
      3 Group (Pvt): -
    3rd match "xx" (String private was not found, so [^\d+] is used (any character not a number))
      1 Group: -
      2 Group: "xx"
      3 Group (Pvt): -
    4th match "PRIVATE33"
      1 Group: 33
      2 Group: -
      3 Group (Pvt): "PRIVATE"
    Now let's look at your code:
    foreach (Match match in Regex.Matches(input, pattern))
    if (match.Groups[1].Success)
    privateDocument += match.Groups[1].Value + "\n";
    else
    publicDocument += match.Groups[2].Value + "\n";
    The Groups-Property of the Match contains 4 values. At index 0 there's the match itself. Index 1, 2 and 3 contain the
    three groups I've described above. So first you check if match.Groups[1].Success. That group is the first Group that stands for [\d+]. That group is succeeded when the string PRIVATE was found and it is followed by a number. With your Input string
    the first and fourth match are succeeded for that one. Then you're adding that Number to your privateDocument-string-variable.
    In the else-block you're adding the Groups[2].Value to the publicDocument-string-variable. That's the second group that stands for  [^\d+]. So it is used for matches 2 and 3 with the two strings "xxPRIVATE" and "xx".
    That's it.
    I would recommend you to install a tool to play around with Regex. My favourite is Expresso. You can download it here:
    http://www.ultrapico.com/expressodownload.htm
    Thomas Claudius Huber
    "If you can't make your app run faster, make it at least look & feel extremly fast"
    My latest Pluralsight-courses:
    XAML Layout in Depth
    Windows Store Apps - Data Binding in Depth
    twitter: @thomasclaudiush
    homepage: www.thomasclaudiushuber.com

  • Question about creating regular expression

    Hi!
    I am creating parser for the specific configuration file. Now I have got small problem: I need to find the line with text in format "key value".
    For example I have this text file:
    entry {
         key value
         key2 value2
         entry2 {
         }I wish to find, using java.regex, these two lines: "key value" and "key2 value2". But how?

    Is your problem that you don't understand regular expressions? If so then this might help. Or is your problem you don't understand Java regular expressions? If so then this might help. Or is your problem that you don't understand how to read lines of a file? If so then this might help.

  • Little help with this regular expression ?

    Greetings all,
    My string is like "P: A104, P105, K106" and I tried to split it using following regular expression ,but seems even though it returns 'true' as matched, it does not split the string.
    Finally what I want is String is array like {"P:","A104","P105","K106"}
    What seems to be the problem with my regular expression?
           String PAT1="[a-zA-Z]:\\s([a-zA-Z]\\d{1,}([,]\\s)?)*";
         String inp="P: A104, P105, K106";
         Pattern p=Pattern.compile(PAT1);
         System.out.println(p.matcher(inp).matches());
         String strs[]=inp.split(PAT1);
         for(String s:strs){
              System.out.println("part  "+s);
         }

    pankajjaiswal10 wrote:
    You can also use split(":|,")No, that will remove the colon and leave the whitespace intact. My understanding is that the OP wants to keep the colon and remove the commas and whitespace. I would use this: String[] strs = inp.split(",?\\s+");

  • Question related to Regular Expressions

    Hello,
    I have the following Java program where i would like to accept words which contain the following characters
    [A-Za-z ./-]*
    Letters A-Z a-z
    Other characters . / - space
    public static void main(String args[]) {
          String regex = "[A-Za-z _./-]*";
          String input = "Hello-how--are you--";
        boolean isMatch = Pattern.matches(regex, input);
        System.out.println(isMatch);//return true
      } The previous code accepts all the apperances of dashes, but i wouldn't like to accept dashes which are next to each other.
    I would like to accept words like ab-cd-ef-gh but i wouldn't like the dashes to be -- like this, next to each other i would like to have at least one character between them.
    Accepted How-are-you-today
    Not accepted hi- or az--z
    What am i supposed to do in order to have the desirable result?
    Thanks, in advance!

    DarrylBurke wrote:
    sabre150 wrote:
    All regex are obvious and no documentation is required. That is the philosophy I used for many years so as to keep me permanently in work.And one fine day we'll see a forum post:
    Can someone help explain this regex to me? The developer who wrote it has since retired.
    edit Couldn't post the regex due to the forum's limit of 7500 characters :(;-)Yep - I will then suggest that they supplement my pension and pay me an exorbitant amount to fix their problem.

  • Very basic questions about how Airport Express works

    I'm using a non-Apple wireless router at home. I'd like to stream music from my iBook to my stereo. Will an Airport Express do that? Will it get confused that there's another access point? Can my iBook receive streaming radio via the non-Apple wireless router and send it to Airport Express?
    Alternatively: can I simply replace my non-Aple wireless router with an Airport Express? Will an Airport Express work as a wireless router? Will it to DHCP and NAT so that multiple computers can connect to the Internet through it?
    Thanks.

    johnbkim, Welcome to the discussion area!
    I'd like to stream music from my iBook to my stereo. Will an Airport Express do that?
    Yes
    Will it get confused that there's another access point?
    You would simply configure the AirPort Express (AX) to join your current wireless network.
    Can my iBook receive streaming radio via the non-Apple wireless router and send it to Airport Express?
    To stream non-iTunes items you will need to use Airfoil.
    Alternatively: can I simply replace my non-Aple wireless router with an Airport Express?
    Yes as long as you don't have any devices connected to that router via Ethernet.
    Will it to DHCP and NAT so that multiple computers can connect to the Internet through it?
    Yes it is a router.

  • Why does this regular expression match (sh)?

    I'm trying to have a yes/no prompt which accepts y, n, yes, no, and is case insensitive. I thought this would work:
    until [[ "$yesno" =~ no?|y(es)? ]]
    do
    read "Continue (yes/no)?" reply;
    yesno=`tr '[:upper:]' '[:lower:]' <<< "$reply"`;
    if [[ "$yesno" =~ no? ]]
    then
    exit 0;
    elif [[ "$yesno" =~ y(es)? ]]
    then
    # stuff to do
    else
    "Invalid input!";
    done
    The problem is ? seems to act more like a wildcard. I tested yn, and it matches. In fact as long as the first character is a Y, y, N, or n, it returns true. The only time ? acts the way it should (match preceding character once or none), is when another character follows it:
    # 'non' and 'noun' will match
    if [[ "$1" =~ nou?n ]]
    then
    echo "$1 matches";
    else
    echo "$1 does not match";
    fi
    I would like to know why it's working like this, and how do I fix it?

    Instead of calling an external program, tr, you could let bash do the case conversion with parameter expansion:
    yesno=${reply,,}
    See 3.5.3 Shell Parameter Expansion.  This is more compact but more cryptic. Take your choice.
    Or you could obviate the need for case conversion altogether by having bash do case-insensitive comparisons:
    shopt -s nocasematch
    But then, to prevent the nocasematch setting affecting the rest of the script, you'd have to save the old value of nocasematch and reset it when you've finished, or carry out the comparisons in a subshell (in which case any other variable settings done in the subshell will also be lost when the subshell ends), so I think it would be more hassle than it's worth.
    Last edited by nh (2009-11-16 17:16:04)

  • Use a regular expression to do this...

    I need to process this line : "STRTsomeEND.STRTsome2END.STRTsome3END"
    to get an array with this values :
    String[] processedLine = {
    {"STRTsomeEND."}
    {"STRTsome2END."}
    {"STRTsome3END."}
    I tried to use this regular expression to do the work: (STRT[.*]END.)+ but doesn't work. Also I tried with this expresion STRT[.*]END. But I only got the first ocurrence ("STRTsomeEND") .
    Can anybody help me?

    zkropotkine wrote:
    1) "." is a regex flag.I saw in the table and it said that the "." symbol doesn't need the escape: )
    when you ask a question and then someone gives you advice you should
    give them the benefit of the doubt (for at least a little while).
    did you take a moment to try to understand what i was saying about escaping the "."?
    anyway, your regex should be:
    (START)(.*?)(END)\ \ .
    the "?" after the "\*" means "reluctant". you dont want the ".\*" to grab up everything.
    with the reluctant modifier "?" the regex should stop and grab the first available "END".
    and finally, if you meant the "." at the end of "STARTsomethingEND." literally then:
    you need to escape the "."

  • Simple question about regular expressions

    Hi,
    Using Java's regular expression syntax, what is the correct pattern string to detect strings like the following :-
    AnnnnnA
    where A = a single (fixed) alphabetic character and
    n = at least one but possibly many digits [0-9].
    Example strings to be searched :-
    A45A (this should match)
    A3A (this should match)
    A3446655577A (this should match)
    A hello world A (this should NOT match as no digits are present between the A's).
    Thanks.

    A least one digit "A.*\\d.*A"
    Only digits "A\\d+A"

  • Question on regular expression.

    Is there a regular expression that can exclude a set of literals?
    For example, if the input string has the word 'abc' or 'xyz'
    evaluating the reg expression should return false/Not Matched.
    The expression
    (abc)|(xyz)
    will do the opposite of what I want.
    Is there a way to create an expression that will produce the
    opposite results of the above expression?
    Thanks.

    Unfortunately I don't see (!) operator in the regular
    expression
    syntax.I believe Monica was referring to the general Java language way of negating a boolean expression. if (!str.matches(".*abc.*def.*")) {
        // do stuff because this string doesn't match the regex
    } Depending on your specific needs, something like that may work, or something like if (str.matches(re1) && !str.matches(re2)) { ... } Or you may want to look at negative lookahead and lookbehind. They're mentioned in the API docs, but not explained. Try googling, or check out this site:
    http://www.regular-expressions.info/lookaround.html

  • 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 (                                                                                                                                                                                                                                                    

Maybe you are looking for

  • LV 8.0 PDA "unknown error"

    Whenever i try to build this VI, I get an unknown error prompt. I have attached the VI's for reference. Attachments: Filedialog.vi ‏20 KB y2kserflnme.vi ‏29 KB

  • 6th Gen Nano not found in windows 7

    Ok so i just got a 6th gene iPod nano, i have been trying to set it up, but my computer won't recongize it (windows 7). I have tried everything, i have uninstalled and reinstall itunes, i have done the misconfig, i have reset the ipod, i have used di

  • When I save a document with digital signature, it crashes.

    When I Try to save a PDF document that have a digital signature, the program don't respond and I must to close it. When I open the pdf, have a digital signature but is not valid. Before of adobe cloud it works perfect. Thanks, Ferran

  • BADI to get characteristics of class in classification tab at MM01 / MM02.

    Hi all,          Is there any user exit or BADI to get all characteristics entered at the classification tab while creating or changing a material (MM01/MMO2) before saving. Regards, Chinna

  • Average of last 30

    I am trying to calculate inventory turnover ratio. This involves dividing the cost of goods sold for the last 30 days by the average daily inventory of the last 30 days. I have the formula for daily inventory, but what would be the formula to calcula