Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search with wildcards?

Status
Not open for further replies.

doctorjellybean

Programmer
May 5, 2003
145
This thread got me thinking


I need to search in a text file for all instances of text which contains [104673]. The numbers itself are different on each line, and the amount of numbers too, e.g.

[7712]
[66436]
[104673]
[00:01.00]

So basically I need to do a wildcard search for all instances of [*] and replace it with an empty string (the [] brackets included).

Would this FastStrings.pas unit do it, or is there another way. I'm not even sure if FastStrings.pas would work in D2007.

Thank you.
 
Fast strings is just to manipulate strings the usual way, but written in x386 assembly for speed.

I think you should check out
for this problem. It is a subset implementation of the PCRE (Perl Regular Expression) library. It works very well and is free.

You can then use one of the Replace methods to find and replace occurrences of '(?-g)\[.*\]' (matches all the lines you supplied) or '(?-g)\[[0-9]*\]' (doesn't match the last line you supplied as it has non-numeric digits in it) with '\[\]'.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top