need a reg expression

  • Thread starter Thread starter AAaron123
  • Start date Start date
A

AAaron123

I want to search my .vb files for lines that do not contain an underline
followed by Menu.

I tried [!_].*Menu as a regular expression but I guess that must mean that
it must contain a character that is not an _ followed by Menu.

Is that correct?

what would work?

thanks
 
I want to search my .vb files for lines that do not contain an underline
followed by Menu.

I tried [!_].*Menu as a regular expression but I guess that must mean that
it must contain a character that is not an _ followed by Menu.

Is that correct?

what would work?

thanks

To negate a character class, you use ^ not !. So, try:

[^_].*Menu

I'm not an expert on regex, so I hope that works :)
 
Thanks that's good to know.

I'm thinking now that
[!_].*Menu
means to find a character other than _ followed by Menu.

I need to find a line that has no _ at all, followed by Menu.

Thanks again



Tom Shelton said:
I want to search my .vb files for lines that do not contain an underline
followed by Menu.

I tried [!_].*Menu as a regular expression but I guess that must mean
that
it must contain a character that is not an _ followed by Menu.

Is that correct?

what would work?

thanks

To negate a character class, you use ^ not !. So, try:

[^_].*Menu

I'm not an expert on regex, so I hope that works :)
 
AAaron123 said:
Thanks that's good to know.

I'm thinking now that
[!_].*Menu
means to find a character other than _ followed by Menu.

I need to find a line that has no _ at all, followed by Menu.

Thanks again



Tom Shelton said:
I want to search my .vb files for lines that do not contain an underline
followed by Menu.

I tried [!_].*Menu as a regular expression but I guess that must mean
that
it must contain a character that is not an _ followed by Menu.

Is that correct?

what would work?

thanks

To negate a character class, you use ^ not !. So, try:

[^_].*Menu

I'm not an expert on regex, so I hope that works :)

Try Expresso. Its a GUI for developing regex. Written in dot.net it will
allow you to test, has some tutorials. The first version I saw had source
but no longer. I don't do regex very much but when I do I find that
Expresso ususally gets me thru.

Found at http://www.ultrapico.com/

LS
 
I'll try that
thanks

Lloyd Sheen said:
AAaron123 said:
Thanks that's good to know.

I'm thinking now that
[!_].*Menu
means to find a character other than _ followed by Menu.

I need to find a line that has no _ at all, followed by Menu.

Thanks again



Tom Shelton said:
I want to search my .vb files for lines that do not contain an
underline
followed by Menu.

I tried [!_].*Menu as a regular expression but I guess that must mean
that
it must contain a character that is not an _ followed by Menu.

Is that correct?

what would work?

thanks

To negate a character class, you use ^ not !. So, try:

[^_].*Menu

I'm not an expert on regex, so I hope that works :)

Try Expresso. Its a GUI for developing regex. Written in dot.net it will
allow you to test, has some tutorials. The first version I saw had source
but no longer. I don't do regex very much but when I do I find that
Expresso ususally gets me thru.

Found at http://www.ultrapico.com/

LS
 
What I meant is that the word Menu should appear and that there should not
be an underscore any place before it.

Are you using ! for negation? Shouldn't it be ^ (see Tom Shelton's earlier
reply.)

Thanks a lot
 
That works.

Are Regular expressions rules the same in, say, Unix, Perl and Windows?


Thanks

And I found out about [^aeiou] and (?<! ) so thanks to Tom Shelton also
 
I'm using Regex.Match and (?<!_.*)Menu works OK if there is just one line
but if I give it the following string it does not match the second line.

fhgfghfh_dfdfg

sdfsdfsdfMenu

sdfsdfsdf

Do I have to call it one line at a time?



Thanks again



I tried with out success: with and without RegexOptions.Multiline.

Also tried with out success: ^(?<!_.*)Menu

Not really sure what these constructs mean, just trying things.
 
Thanks for all the help.
Besides what you showed me my underlying problem was the string contained
CR(13) for line endings.
I checked a RichTextBox.Text and it contained LF for line endings.
I expected CRLF since I thought the was the way of Windows.

Any way I replace CR wit LF and replace works OK now.

Must be Regex looks for LF.
Sound right to you?

I'd like my code to act the same as
VS2008/Edit/Find In Files/Use Regular Expressions

Do you know or can you surmise if it uses any of the following?
Take a guess otherwise - it would be a better guess than mine.


The RegexOptions Enumeration contains:

Multiline
ExplicitCapture
Singleline
IgnorePatternWhitespace
ECMAScript
CultureInvariant

Thanks again
 
No problem.


In UNIX, yes. A line termination is a LF. In Windows typically, no. A
line termination is typically a carriage return and linefeed
combination. I've not tested this under .NET's engine, but it could be
using UNIX style line terminations.


I do not yet own VS2008 (I saw no good reason to upgrade from 2005).
I'm not sure if this particular sample was included with VS2005,
because I have no samples installed.

If you could give a summary of what it is you're trying to accomplish,
or perhaps someone else could help out on this question.

No need.
You solve my problem.
Mostly just curious now.
Thanks
 
Back
Top