Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    8
    Rep Power
    0
    I'm looking through the site, now. Thank you. It's actually a lot to go through, but I think it's really important. I've got a solution, now, to get everything into appropriate arrays. It's very similar to what we are already doing, but it loads the results into an object. This is going to be useful in many other places. Boy, I've run into a LOT of really complicated regex.. I'll show you an example:

    @^(?:^|\x20{4})((??:\w[^;\r\n:]+\w);\s*)+(??:\w[^\r\n]+\w)+))(?:$|[\r\n]+|\x20{4})@m

    @ - custom delimeter
    ^ - not a newline
    (?: - cannot be a newline
    | - or
    \x20{4}) - four occurrences of \x20 (unknown).
    ( - capture
    (?: - what could be
    (?:\w[^\r\n:] - a possible word that does not contain ; or a line break...

    So I mean, obviously I'm way off. I gotta get through that website you gave me. When I see long regex strings like this, I'm more curious as to what kind of mind-enhancing drugs the author's on than I am able to figure out what they're saying, still.

    So anyway, really thanks for the website. I'll let you know when I'm through it.
  2. #17
  3. Turn left at the third duck
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Location
    Nelson, NZ
    Posts
    112
    Rep Power
    93
    When I see long regex strings like this, I'm more curious as to what kind of mind-enhancing drugs the author's on than I am able to figure out what they're saying
    What I do is break it into several lines in RegexBuddy , in PCRE mode, adding (?x) at the top of the pattern to turn on the comment / white-space mode.

    So, for instance, applying this to the regex you sent:

    Code:
    (?x)  # activate comment mode
    ^ # anchor beg of string
    (?:^|\x20{4}) # non-capturing group: beg of string OR four spaces
    # BUT WE HAVE ALREADY ANCHORED!!! And could we just use [ ]{4}
    ( #START capture Group 1
    (?:(?:\w[^;\r\n:]+\w);\s*)+ # One or more instances of {ONE word character followed by one or more characters in [^;\r\n:] followed by ONE word character followed by a semi-colon followed by optional space
    # ON THE LINE ABOVE, THE SECOND (?: DOES NOT SERVE ANY FUNCTION, IT CAN BE TAKEN OUT
    (?:(?:\w[^\r\n]+\w)+) # Same as above but no semi-colon
    # THIS TIME, IT IS THE FIRST (?: THAT DOES NOT SERVE ANY FUNCTION. TAKE IT OUT!
    ) # End of Group 1
    (?: # Non-capturing group
    $ # End of string 
    | # Or
    [\r\n]+ # One or more new lines
    | # Or
    \x20{4} # Four spaces (WHY NOT [ ]{4} ?)
    ) # end non-capturing group
    As you can see, several bugs immediately jump at you (the comments in upper-case).

    Wishing you a fun day
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo