Results 1 to 4 of 4

Thread: [RESOLVED] need help with regex

  1. #1

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Resolved [RESOLVED] need help with regex

    Hi,

    I normally use the .Replace function in asp.net , which works fine, but this time I want it to be more strict.
    The string I will be looking for will contain A-Z a-z 0-9 $ _
    ex.
    $EUROPE_FRANCE
    $EUROPE_FRANCE_PARIS
    ...
    There is no blank space between the words and it always start with a $ sign.

    So my main issue with the .Replace function is , if I search for '$EUROPE_FRANCE' it will detect this twice '$EUROPE_FRANCE' and '$EUROPE_FRANCE_PARIS' . I have no clue about the regex syntax, but i read it's possible, so I was wondering if there is way to specify for regex to only search for exact match? Or even there is another function in asp.net that will allow me to do this.

    Thank You

  2. #2
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: need help with regex

    Hi,

    Give this syntax a try:-

    Code:
    \$([0-9a-zA-Z_]{1,})
    This will select any Single Word String that starts with a dollar character.

    Hope that helps.

    Cheers,

    Ian

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: need help with regex

    Hey,

    For an online resource to help you with constructing the Regular Expression, be sure to check out this site:

    http://gskinner.com/RegExr/

    I use it all the time

    Gary

  4. #4

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: need help with regex

    @IanRyder Thanks, the syntax you provided was exactly what i needed
    @gep13 , nice tool , i will bookmark it.

    thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width