FIND/REPLACE with REGEX

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
+sveinajoha+
Posts: 5
Joined: Wed Mar 18, 2009 12:24 pm

FIND/REPLACE with REGEX

Post 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?
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: FIND/REPLACE with REGEX

Post by DataMystic Support »

Easy:

Find

Code: Select all

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

Code: Select all

<a>$1...</a>
+sveinajoha+
Posts: 5
Joined: Wed Mar 18, 2009 12:24 pm

Re: FIND/REPLACE with REGEX

Post 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
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: FIND/REPLACE with REGEX

Post 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.
Post Reply