LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default VBA- Finding texts built from regex patterns


I need to recognise patterns in text starting with a specific variable text value and ending in 0-3 numeric values.




For example:




I have several strings of text that I am searching for at the start of a text string:




S

FDC

PP

Doctor




So I will want to loop through these (already in an array) and test whether a text string starts with these values and ends with 0-2 numeric digits:




i.e. Text string "S01" is true

"PQ" is false

"FDC99" is true

"Doctor" is true

"Dr01" is false




I have not worked much with Regex before so am struggling to workout how I recognise the pattern for each of the strings. Any ideas?




If I do find ,matches, I will then replace the text part with a different string




i.e. "S" is replaced by "Stamps "
"FDC" is replaced by "First Day Covers "


"PP" is replaced by "Presentation Packs "
"Doctor" is replaced by "Doctor Who "



The replacement texts are in the same array BinderNames(1 To BinderCount, 1 To 2) so the first and 2nd entries in each row are the search text and the replacement text.




Is there a simple way of using Regex to do this?
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Regex Patterns Geoff K Excel Programming 1 October 18th 09 02:08 PM
Regex exception Geoff K Excel Programming 4 October 17th 09 11:53 AM
Regex techniques Dave Runyan Excel Programming 5 April 28th 07 12:17 AM
RegEx Replacement patterns CodeSponge[_2_] Excel Programming 2 February 5th 05 07:39 AM
Regex Question William Barnes Excel Programming 5 January 2nd 04 11:57 AM


All times are GMT +1. The time now is 02:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"