Page 1 of 1

FIND/REPLACE with REGEX

Posted: Sat Apr 25, 2009 8:14 pm
by +sveinajoha+
Im trying to strip the text lenght of text between two html tags.
I restrict to the text between the wanted tag, and have tried different FIND/REPLACE regex expression in a subfilter.

Example: <a>this is a sample text between an html tag pair </a>
Wanted output: <a>this is a sample... </a>
(only 16 characters and adding "...")

Do anyone have any sugesstions how to use regex with FIND/REPLACE to count the lenght and strip of unwanted characters?

Re: FIND/REPLACE with REGEX

Posted: Mon Apr 27, 2009 8:44 am
by DataMystic Support
Easy:

Find

Code: Select all

<a>([^<>]{1,16}?)([^<>]*)</a>
Replace with

Code: Select all

<a>$1...</a>

Re: FIND/REPLACE with REGEX

Posted: Tue Apr 28, 2009 6:10 am
by +sveinajoha+
Thank You so much :)

I obviously have missed something important when reading the docs...
But still a bit confused about "$1", is this a variable I have to declare or is this an TextPipe "internal container" always containg the last search match?

Regards

Re: FIND/REPLACE with REGEX

Posted: Tue Apr 28, 2009 10:15 am
by DataMystic Support
The latter is correct - $1 is a placholder that contains the first bracketed (...) part of a match. $2 holds the 17 characters and onwards.