regex match search or not to search

Re: System.Text.RegularExpressions.Regex, C#

lets call the string to be searched target string

Desired Result: Efficiently Match a regular expression to target string. WHOLE target string should be consumed.

Actual Result: The Match searches as documented until it finds a match WITHIN the target string.

Can I indicate to method Match to consume whole target string or fail efficiently? with options or lookback

Perhaps the naming throws me. Boost library has two methods for their version of regex ...regex_match and regex_search
Here is an excerpt from Boost site
>>>>>>>>>>>>>>>>
http://boost.org/libs/regex/doc/regex_match.html

The algorithm regex _match determines whether a given regular expression matches all of a given character ...

Note that the result is true only if the expression matches the whole of the input sequence. If you want to search for an expression somewhere within the sequence then use regex_search.
>>>>>>>>>>>

Perhaps I dont know how to use regex.Match efficiently
I understand
..if regex.Match return type Match with index of 0 and Length X, where X ..equals length of original target string ...
..then whole target string was consumed.
This could be inefficient for large target strings. Is this unrealistic?
I would like regex.match not to search through all text but to fail quickly.

It seems to me if I wanted regex.Match to search through the text I would precede all regular expressions with a optional wildcard such as

.* (dot asterisk)

Thanks in advance for your insights.

[1823 byte] By [software_writer_nyc] at [2008-3-3]
# 1

hi,

how can you match or search a text without scanning it first?

Match.Groups[0] = your entire text usually

http://www.regular-expressions.info/

for example if you want to specify a critaria to skip matching then you can use if string.Contains("value") //match

but like that you scan your string twice

hope this helps

shakalama at 2007-9-4 > top of Msdn Tech,.NET Development,Regular Expressions...

.NET Development

Site Classified