Insert text around expression

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
JB

Insert text around expression

Post by JB »

I have been trying to automate the process of inserting text around a list of numbers. I have tried various find and replaces and macros, but cannot seem to get it to work. Any suggestions??

"123456"
"234567"
"456678"


needs to be
membernumber="123456" or

Thanks in advance!!

JB
Andreas

RE: Insert text around expression

Post by Andreas »

Try the following regular expressions (make sure the "Regular expression box in the lower left corner of the replace dialog is selected):

Search for

"[0-9]+"

replace by

membernumber=& or

Explanation:
[0-9] means any character from 0 to 9 ([] means any character in the brackets, and you can give ranges and/or lists of characters, e.g. [a-cefg]...)
+ means at least one of the expressions to the left of it (which is in this case the [] expression)
The quotes are just what they are,
so in total you are looking for a quote, followed by one or more digits, followed by a quote.

& in the replacement expression is replaced by the text that was found.

Btw, there is a lot of help on regular expressions in the Textpad Help.
HTH
Andreas
Post Reply