REGEX NON MATCHING - LINES NOT CONTAINING STRING LOGIC

J

jason

The following vb code displays every line that has a particular string
in it. How do I list every line that does not have that string. "!"
does not seem to work for me and not sure where to place it in match
logic.


<vb code>

readin("linetest.txt")
dim linex as string
linex="line"

Dim xxx as string
xxx = "^(.+)"+linex+"(.+)$"
Dim regexp2 as Regex = new Regex (xxx, RegexOptions.IgnoreCase or
RegexOptions.Multiline )


Dim objMatch as Match
dim z as string
For Each objMatch in regexp2.Matches(session("readin"))
z = objMatch.ToString()
response.write(z + "<br>")
Next

</vb code>

Thanks in advance for any help or info.
 
C

Craig Deelsnyder

The following vb code displays every line that has a particular string
in it. How do I list every line that does not have that string. "!"
does not seem to work for me and not sure where to place it in match
logic.


<vb code>

readin("linetest.txt")
dim linex as string
linex="line"

Dim xxx as string
xxx = "^(.+)"+linex+"(.+)$"
Dim regexp2 as Regex = new Regex (xxx, RegexOptions.IgnoreCase or
RegexOptions.Multiline )


Dim objMatch as Match
dim z as string
For Each objMatch in regexp2.Matches(session("readin"))
z = objMatch.ToString()
response.write(z + "<br>")
Next

</vb code>

Thanks in advance for any help or info.

The caret ^ is usually used inside a char grouping to specify 'all chars
but these'....check out regexlib.com, here's there cheat sheet:

http://regexlib.com/CheatSheet.htm

a very good site where you can even test your expression...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top