Steffan Harris
Steffan Harris

Reputation: 9326

Regex to match a single character

I was wondering if there was a regex availabe that can match a string and search for a "=" in the string.

Upvotes: 2

Views: 6428

Answers (2)

Andrew White
Andrew White

Reputation: 53496

Yes, but why? I simple string search for "=" is usually what you want (see String.IndexOf). Doing a search for "=" using a regex means just using "=" as the regex, nothing special.

If you want to match rather than search you can use the regex .*=.*

Is this what you wanted or am I missing something?

Upvotes: 4

Macy Abbey
Macy Abbey

Reputation: 3887

/[=]+/

That will match if there is an = character one or more times anywhere in the string.

Upvotes: 2

Related Questions