Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 4th, 2008, 03:18 PM
Newbie
 
Join Date: Aug 2008
Posts: 12
Default String matching

I've got a script which basically goes line by line through an external file, and hands it to the screen in a slightly parsed form.

I'd like to apply another bit of parsing to what's coming in though, and specifically look for a pattern matching "[[form=x]]" where x can be any number.

If that string is found, I'd like to grab the "x" part, pass it through a subroutine, and then replace the "[[" and "]]" and everything in between with a variable.

I think I can do the latter bit myself, it's just the matching the string (that is, any section of the line starting with "[[file=" and ending with "]]") and grabbing the number that I can't figure out.

Any help is much appreciated.
Reply
  #2  
Old September 5th, 2008, 01:19 PM
Newbie
 
Join Date: Aug 2008
Posts: 12
Default

Update: I sorted this out myself using a regular expression. I suspected that would be the answer, but it was easier than I thought to get it working.

If anyone's interested, this is the code I used to grab the number in the [[form=]] tag:

Code:
Set oRegEx = New RegExp
	With oRegEx
		.Pattern = "\[\[form=.*?\]\]"
		.IgnoreCase = True
	End With
Set temp = oRegEx.Execute(line)
temp = Replace(temp(0),"[[form=","")
temp = Replace(temp,"]]","")
Reply
  #3  
Old September 5th, 2008, 06:06 PM
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Age: 32
Posts: 2,360
Default

Thanks for posting the answer. I was about to answer that I could hard code it, but what you really need were regular expressions, and I had never used them in ASP. Glad we have that on file now :-)

Jared
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles