Need find/replace expression to truncate length

General questions about using TextPad

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

Post Reply
Pinggolf
Posts: 4
Joined: Tue Dec 07, 2004 7:36 pm

Need find/replace expression to truncate length

Post by Pinggolf »

I would like to have a find/replace expression to truncate a field if it is longer than a specified length.

For example:
If the length of field <address></address> is longer than 60 characters, I would like to truncate the field to 60 characters. I use the following search to find each occurrence:
<address>.{61,}</address>

but I am not sure what to use to replace the field with the first 60 characters.

Thanks for any help.
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

You got the right idea, but you have to capture the data using the ().
Find (<address>.{60}).*(</address>)
Replace \1\2
I have used POSIX regular expression syntax, which can be selected from the Editor page of the Preferences dialog box. HTH
Then I open up and see
the person fumbling here is me
a different way to be
Pinggolf
Posts: 4
Joined: Tue Dec 07, 2004 7:36 pm

Post by Pinggolf »

Thanks!
Post Reply