#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    köln, germany
    Posts
    51
    Rep Power
    12

    Match after n-th occurrence of something


    Hello,
    I have a string full of parameters separated by '|'s and am looking for a way to match the value after the n-th '|'. ( I know i could split them but ... you know ...)

    I'm sure there a way to do this in regex ... but how??

    my string looks something like this:

    0|||word||otherword|||string_to_replace||

    /\|{8}(.*)$/

    is a really feeble attempt and obviously doesn't work but I should spare you of all the versions I tried.

    Thankful for your hints:
    thomas
  2. #2
  3. No Profile Picture
    User 165270
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    497
    Rep Power
    937
    Try it like this:

    Code:
    ^(?:[^|]*\|){8}([^|]*)

    Comments on this post

    • jwmoebius agrees
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    köln, germany
    Posts
    51
    Rep Power
    12
    Cool. Yeah that helped! Cheers!
  6. #4
  7. No Profile Picture
    User 165270
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    497
    Rep Power
    937
    Originally Posted by jwmoebius
    Cool. Yeah that helped! Cheers!
    No problem.

IMN logo majestic logo threadwatch logo seochat tools logo