views:

73

answers:

3

Hi everyone, I'm just trying to remove spaces from some line:

"(jan | feb | mar | apr | may | jun | jul | aug | sep | oct | nov | dec)\.(\s+),(\s+)(\d{4})"

in my solution and try to do that with find and replace and somewhat don't know how to enter space character in this dialog box. And as I started with some regx what is the difference between:

"(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\.(\s+),(\s+)(\d{4})"

and

    "(jan | feb | mar | apr | may | jun | jul | aug | sep | oct | nov | dec)\.(\s+),(\s+)(\d{4})"

regex wise? Thank you for any help.

A: 

If you put the spaces in, it will require space characters to be there (except when you can enable the "extended" regex syntax).

brianary
A: 

The second will search for those terms, including spaces. They mean something in regular expressions. It's not whitespace-insensitive. This can be a good or bad thing, depending on how you look at it.

Bottom line: if you want to match spaces, insert spaces. Otherwise, don't.

Samir Talwar
A: 

In order to match both with and without the spaces use [ ]* to include 0 or more space characters

"(jan[ ]*|feb[ ]*|mar[ ]*|apr[ ]*|may[ ]*|jun[ ]*|jul[ ]*|aug[ ]*|sep[ ]*|oct[ ]*|nov[ ]*|dec[ ]*)\.(\s+),(\s+)(\d{4})"
Jeremy E