473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

String matching

14
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.
Sep 4 '08 #1
2 2028
Zetten
14
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:

Expand|Select|Wrap|Line Numbers
  1. Set oRegEx = New RegExp
  2.     With oRegEx
  3.         .Pattern = "\[\[form=.*?\]\]"
  4.         .IgnoreCase = True
  5.     End With
  6. Set temp = oRegEx.Execute(line)
  7. temp = Replace(temp(0),"[[form=","")
  8. temp = Replace(temp,"]]","")
Sep 5 '08 #2
jhardman
3,406 Expert 2GB
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
Sep 5 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # Matching string patterns # # Sometimes you want to know if a string is of # particular pattern. Let's say in your website # you have converted all images...
11
by: Martin Robins | last post by:
I am trying to parse a string that is similar in form to an OLEDB connection string using regular expressions; in principle it is working, but certain character combinations in the string being...
0
by: Tom Warren | last post by:
I found a c program called similcmp on the net and converted it to vba if anybody wants it. I'll post the technical research on it if there is any call for it. It looks like it could be a useful...
19
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not...
10
by: javuchi | last post by:
I'm searching for a library which makes aproximative string matching, for example, searching in a dictionary the word "motorcycle", but returns similar strings like "motorcicle". Is there such a...
5
by: olaufr | last post by:
Hi, I'd need to perform simple pattern matching within a string using a list of possible patterns. For example, I want to know if the substring starting at position n matches any of the string I...
9
by: | last post by:
I am interested in scanning web pages for content of interest, and then auto-classifying that content. I have tables of metadata that I can use for the classification, e.g. : "John P. Jones" "Jane...
0
NeoPa
by: NeoPa | last post by:
ANSI-89 v ANSI-92 Before we get into all the various types of pattern matching that can be used, there are two ANSI standards used for the main types of wildcard matching (matching zero or more...
11
by: tech | last post by:
Hi, I need a function to specify a match pattern including using wildcard characters as below to find chars in a std::string. The match pattern can contain the wildcard characters "*" and "?",...
1
by: Ben | last post by:
I apologize in advance for the newbie question. I'm trying to figure out a way to find all of the occurrences of a regular expression in a string including the overlapping ones. For example,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.