Page 1 of 1

Need find/replace expression to truncate length

Posted: Tue Mar 01, 2005 2:38 pm
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.

Posted: Tue Mar 01, 2005 3:17 pm
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

Posted: Tue Mar 01, 2005 3:38 pm
by Pinggolf
Thanks!