Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts

    REGULAR EXPRE...ahha, somewhat hard

    hey all,
    I have somewhat of an issue here..
    and I can't overcome it right now..

    I have a string that is plugged into a variable..now, I need to test if a GIVEN string contains the variable..but with certain circumstances...
    so...

    I need to match the following..

    mainstring.indexOf(":::"+variable/\s|\,/)!=-1

    now, this won't work...
    basically, I need to see if the MAIN string contains the variable preceded by three (:: :'s , and following by either a comma or nothing..BUT NOT another letter or somesuch....soooooooo....

    hellowhateversomestringstufff:::HELLO YOU, moresgooglygopsomesuch:::HEY YOU, additionalstuffgoeshere::: MORE STUFF

    now, lets say I search for "HEY YOU"....I need to test for the ":::" preceding it, and the "," after it...plus the "HEY YOU" of course...NOW..what if I needed "MORE STUFF"....I need to detect that there is nothing after it...cause some strings could be similiar but not the same..for instance....

    MORE STUFF can't match MORE STUFF FOR ME


    so, even though I am doing an indexOF ....cause I have to test against a long string....I need to find my exact match WITHIN that long string....given the above parameters.

    I've tried different regex's but I can't seem to get it to work always..

    I also did somethgn like:

    var astring = /:{3}variable[\s|\,]/;
    if(mainstring.indexOf(astring) != -1)

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts
    nevermind, I figured it out....
    I had to split things up on the ":::" and then match from there...its works fine..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •