I want to write a regular expression for the following scenario.
If line starts with word "project", then allo开发者_StackOverflow社区w 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.
What about:
/^project[^.]*$/i if you want to select "project"
/^project[^.]+$/i if you need at least one char after project
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 :"
精彩评论