Search colon

E

Eric

Hi: How to i search ":" in a sentence. For eg:


abc efg hij : kkk ddd lll
fda fdasf jfdas fdas fsad

When i read a line i want to skip those lines where ":" is present

data = ts.ReadLine
 
M

McKirahan

Eric said:
Hi: How to i search ":" in a sentence. For eg:


abc efg hij : kkk ddd lll
fda fdasf jfdas fdas fsad

When i read a line i want to skip those lines where ":" is present

data = ts.ReadLine

If InStr(data,":") = 0 Then
' do your thing
End If
 
B

Bobbo

Eric said:
Hi: How to i search ":" in a sentence. For eg:


abc efg hij : kkk ddd lll
fda fdasf jfdas fdas fsad

When i read a line i want to skip those lines where ":" is present

data = ts.ReadLine

Consider using Regular Expressions - in my experience they're much
faster and easier than loops which perform string comparisons --
because you can return an entire matching file in one line of code --
but are tricky to get the hang of.

This site is a good place to start:
http://www.regular-expressions.info/index.html
http://www.regular-expressions.info/completelines.html

This site describes how to use them in ASP:
http://www.4guysfromrolla.com/webtech/090199-1.shtml

And finally this actual expression should match your original problem,
assuming you're using a text file:
^.*:.*$

This looks I just fell on the keyboard, but what it means is:
^.* = a series of 0 or more characters starting at the begining of
the line
: = your search condition, the colon in this case
..*$ = another series of 0 or more characters until the end of the line
 
B

Bob Barrows [MVP]

Eric said:
Hi: How to i search ":" in a sentence. For eg:


abc efg hij : kkk ddd lll
fda fdasf jfdas fdas fsad

When i read a line i want to skip those lines where ":" is present

data = ts.ReadLine

You need the vbscript documentation. You can download it from here:
http://tinyurl.com/7rk6
 
D

Dave Anderson

Bobbo said:
...
And finally this actual expression should match your original
problem, assuming you're using a text file:
^.*:.*$

To take Bobbo's suggestion a bit further, you already know you have a single
line, so you can simply use : as your expression:

In JScript,
if (!/:/.test(data)) { do something }

In VBScript,
Set re = New RegExp
re.pattern = ":"
...
data = ts.ReadLine
If Not re.Test(data) Then
{ do something }
End If
 

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,764
Messages
2,569,567
Members
45,042
Latest member
icassiem

Latest Threads

Top