FIND/REPLACE with REGEX

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

FIND/REPLACE with REGEX

Postby +sveinajoha+ » Sat Apr 25, 2009 8:14 pm

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: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: FIND/REPLACE with REGEX

Postby DataMystic Support » Mon Apr 27, 2009 8:44 am

Easy:

Find

Code: Select all

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


Replace with

Code: Select all

<a>$1...</a>
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

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

Re: FIND/REPLACE with REGEX

Postby +sveinajoha+ » Tue Apr 28, 2009 6:10 am

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: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: FIND/REPLACE with REGEX

Postby DataMystic Support » Tue Apr 28, 2009 10:15 am

The latter is correct - $1 is a placholder that contains the first bracketed (...) part of a match. $2 holds the 17 characters and onwards.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests