Friday, September 5, 2008

Regex problem

Geeeeezz!

It took me so long to understand the difference between \w and \b in Regular Expressions!!!

Although both mark the word boundary, \b is more effective (IMHO). Try search whole word text which is just at the end of a text file. Something like,

....
blah blah blah
....
blah<eof>


If you are searching for text 'blah' (notice the one at the end of file) then \w will skip it. So, better use \b!!

Regex re = new Regex(@"\bblah\b");


Happy coding! =)

8 comments:

  1. Really?
    I can't even figure out how to change 'comments' to some funny phrase like 'reasonable rebuttals'!

    Is that pathetic or what?

    ReplyDelete
  2. Heyyyy Donnnnn!!

    Glad to see you have some sparks left :P

    Well, in my community, u'll be just called a noob :D
    But hey, everybody goes thru tht phase :) its okay!

    ReplyDelete
  3. Yeah but not after three frickin' years!
    I did manage to change it once, but I don't no where to insert 'smartass retorts' in the code..((DUH))

    ReplyDelete
  4. Okay!
    Next post tells some tricks about blogger :)

    ReplyDelete
  5. There's another noob here reading, trying to learn something. (*points at herself*) LOL :D

    ReplyDelete
  6. Its alright!
    I have handled GP.. what else can be worse! =D

    ReplyDelete
  7. Hey people,what's all the fuss about,relax and chill,life is too short for us to be getting Technical.

    ReplyDelete

Talk to me :)