tags:

views:

314

answers:

2

Hi,

I want to write a regular expression for the following scenario.

If line starts with word "project", then allow any type of character after it except "." (dot).

For example:

project is to pick up of discontinued items.

The above line should not get selected and the following lines should get selected:

project :
Project #1

I have created regular expression like this, but it is not working in few scenarios. Can anyone help me correcting my regular expression or creating new RE?

project\s[\s\S^\.]{0,50}

The logic for the above RE is: select string containing word "project", followed by one whitespace character, followed by 0 to 50 characters of all types except dot character.

+4  A: 

What about:

/^project[^.]*$/i if you want to select "project"

/^project[^.]+$/i if you need at least one char after project

RC
Thanks RC.Your RegEx. worked !!!
Shekhar
If an answer works for you, you probably ought to formally accept it.
theraccoonbear
+1  A: 

Try using this regex, ^project\b[:#].*$

The above regex selects the line if it contains project followed by a word boundary (space, tab, comma etc) followed by a : or #. So this will not select "project is to pick up of discontinued items." but it will select "project :"

Jass
Many thanks Jass for help.
Shekhar