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

    Join Date
    Apr 2008
    Posts
    178
    Rep Power
    205

    Negate a complete character set and not one character


    hi,

    if we have to negate a character we do lik

    /[^a]b/

    if i want match, say "find b but not starting with word google"

    /[^google]b/

    it will negate google by taking alphabeters one by one rather than complete word.

    how can i negate the complete word?

    thank you
  2. #2
  3. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,898
    Rep Power
    3887
    Originally Posted by tinystudent
    if i want match, say "find b but not starting with word google"
    Do you mean "find b but it can't have the word "google" immediately before it?

    Code:
    /(?<!google)b/

    Comments on this post

    • ManiacDan agrees : Yay lookarounds!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2008
    Posts
    178
    Rep Power
    205
    in fact, i want to kill this "immediately" i have a crazy source code i am looking to parse. I have read negative lookahead/lookbehind assertion but still not sure if it is possible with regex what i am looking to do

    so i have accepted defeat and after running first regex i will take care of the rest with my lovely php

    however for some feed for your brain i have following string(s)

    {tag1}xxxx{p}ssss{/p}{/tag1}
    {tag1}xxxx{p}ssss{/p}{tag1}
    {tag1}xxxx{tag1}
    {tag1}xxxx{p}ssss{tag1}xxxxx{/tag1}{/p}{/tag1}


    what i am interested is the value that appears with in tag1-pair and SKIP p-tag value IF it does not have a tag1-pair inside it, if it is found then fetch that as well.

    additionally, it is possible that tag1 is incorrectly closed, in that i case i must end my search on finding an opening tag1 without closing the previous and make a separate array of such strings so that i can fix those values.

    does it make sense?

IMN logo majestic logo threadwatch logo seochat tools logo