Autolinking feature with variable content
Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators
Autolinking feature with variable content
When searching through the threads I could not find a solution for the following problem:
Target: To search and replace specific text code with known beginning and ending character but with different "inside" in between into a clickable URL. The simple things can be done with a Find pattern: (§(.*)AAA). But the point is the regex with different characters "inside".
Example:
To search for all text between the beginning character "§" and e.g. the ending character "AAA".
§ 100 AAA should be converted to <a class="myclass" href="http://www.datamystic.com/__100.html">§ 100 AAA</a>
§ 12c AAA should be converted to <a class="myclass" href="http://www.datamystic.com/__12c.html">§ 12c AAA</a>
And here comes the problem:
§ 123d Abs. 1 AAA should be converted to <a class="myclass" href="http://www.datamystic.com/__123d.html">§ 123d Abs.1 AAA</a>
The convention is as follows:
It starts with "§", thereafter is often a blank but not always. But - if necessary - I can arrange that there will be at least one or two blanks after the beginning "§". Thereafter comes an alphanumerical set of characters of 1 till 12 characters without any blank and thereafter one or two blanks and then the closing "AAA".
In other words: If the textpipe container $1 contains e.g. "§ 123d Abs.1 AAA" this should be left as the linking text but in the link itself should only appear "123d" as shown. Or "§ 5 AAA" as "5" in the URL.
Can you help with the regex pattern?
thanks
Target: To search and replace specific text code with known beginning and ending character but with different "inside" in between into a clickable URL. The simple things can be done with a Find pattern: (§(.*)AAA). But the point is the regex with different characters "inside".
Example:
To search for all text between the beginning character "§" and e.g. the ending character "AAA".
§ 100 AAA should be converted to <a class="myclass" href="http://www.datamystic.com/__100.html">§ 100 AAA</a>
§ 12c AAA should be converted to <a class="myclass" href="http://www.datamystic.com/__12c.html">§ 12c AAA</a>
And here comes the problem:
§ 123d Abs. 1 AAA should be converted to <a class="myclass" href="http://www.datamystic.com/__123d.html">§ 123d Abs.1 AAA</a>
The convention is as follows:
It starts with "§", thereafter is often a blank but not always. But - if necessary - I can arrange that there will be at least one or two blanks after the beginning "§". Thereafter comes an alphanumerical set of characters of 1 till 12 characters without any blank and thereafter one or two blanks and then the closing "AAA".
In other words: If the textpipe container $1 contains e.g. "§ 123d Abs.1 AAA" this should be left as the linking text but in the link itself should only appear "123d" as shown. Or "§ 5 AAA" as "5" in the URL.
Can you help with the regex pattern?
thanks
Re: Autolinking feature with variable content
Sorry,
I have forgotten to include that such replacement shout not be made if the text is already part of a link like in
<a href="http://www.datamystic.com/__12c.html">§ 12c AAA</a>
This is the case if the ending tag </a> comes directly after "AAA". In some case there may be a blank character between AAA and </a>.
I have forgotten to include that such replacement shout not be made if the text is already part of a link like in
<a href="http://www.datamystic.com/__12c.html">§ 12c AAA</a>
This is the case if the ending tag </a> comes directly after "AAA". In some case there may be a blank character between AAA and </a>.
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Autolinking feature with variable content
Hi Gerd,
Use EasyPattern Search/Replace
Replace with:
Are you a customer? I can't give you the final piece (to only replace if not inside a link already) until you are!
Use EasyPattern Search/Replace
Code: Select all
§[optional space, capture( 1 to 12 alphanumeric), 1-2 space]AAA
Code: Select all
<a class="myclass" href="http://www.datamystic.com/__$1.html">$0</a>
Re: Autolinking feature with variable content
Hi Simon,
Yes, I am a customer. This is the receipt number I got from you: AV1316220
But you totally overstimate my knowledge of Easy Pattern or TextPipe. I work with Textpipe just 1-2 times a year, most times only at the end of the year.Therefore the pattern
§[optional space, capture( 1 to 12 alphanumeric), 1-2 space]AAA
does not tell me anything. How does the REAL pattern look like in the brackets [ ]
"capture( 1 to 12 alphanumeric), 1-2 space" is probably not the pattern.
The error message reads: alphanumeric is not a valid keyword.
I understand the "Replace with" Code like
$0 - is replaced by the entire matched text
$1 - is replaced with the first parenthesised expression.
but how reads the real EasyPattern Search/Replace code?
It seems to me that the code does not lead to the expecting result. Examples:
from § 12c AAA --> the container $1 should include: 12c
from § 100 AAA --> the container $1 should include: 100
from § 123d Abs.1 AAA --> the container $1 should include: 123d
Target: Extract for the container $1 the contents from a string "§ ... AAA" after the first SPACE until the next SPACE. Example:
from § 123d Abs.1 AAA --> the container $1 should include: 123d
Thanks
gerd
Yes, I am a customer. This is the receipt number I got from you: AV1316220
But you totally overstimate my knowledge of Easy Pattern or TextPipe. I work with Textpipe just 1-2 times a year, most times only at the end of the year.Therefore the pattern
§[optional space, capture( 1 to 12 alphanumeric), 1-2 space]AAA
does not tell me anything. How does the REAL pattern look like in the brackets [ ]
"capture( 1 to 12 alphanumeric), 1-2 space" is probably not the pattern.
The error message reads: alphanumeric is not a valid keyword.
I understand the "Replace with" Code like
$0 - is replaced by the entire matched text
$1 - is replaced with the first parenthesised expression.
but how reads the real EasyPattern Search/Replace code?
It seems to me that the code does not lead to the expecting result. Examples:
from § 12c AAA --> the container $1 should include: 12c
from § 100 AAA --> the container $1 should include: 100
from § 123d Abs.1 AAA --> the container $1 should include: 123d
Target: Extract for the container $1 the contents from a string "§ ... AAA" after the first SPACE until the next SPACE. Example:
from § 123d Abs.1 AAA --> the container $1 should include: 123d
Thanks
gerd
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Autolinking feature with variable content
Here you go gerd - I should have used
instead of
Code: Select all
letter or number or <. >
Code: Select all
alphanumeric
- Attachments
-
- gerd.zip
- (712 Bytes) Downloaded 589 times
Re: Autolinking feature with variable content
Thanks, Simon.
I guess I have to upgrade to a new version. I have Text Pipe 8.1.1 of TextpipeLite and cannot load the filter.(expecting file type <= 89, reading type:98)
Error reading TFListerList: Error reading TInputObject
To which version do I need to upgrade? TextpipeLite or Standard? Shall I do it directly at you or at your European partner "shareit" in Cologne?
If your filter in the zip file is identical with the above pattern code then there is still a problem:
Text from Trial Area in version 8.1.1.
dummy text § 5a AAA dummy text § 5 AAA
dummy text dummy text (§ 4 Abs. 1 AAA) dummy text
dummy text <a class="myclass" href="http://www.datamystic.com/__5.html">§ 5 AAA</a> dummy text
leads with §[optional space, capture(1 to 12 letter or number or <. >), 1-2 space]AAA to
dummy text <a class="myclass" href="http://www.datamystic.com/__ 5a.html">§ 5a AAA</a> dummy text <a class="myclass" href="http://www.datamystic.com/__ 5.html">§ 5 AAA</a>
dummy text dummy text (<a class="myclass" href="http://www.datamystic.com/__ 4 Abs. 1.html">§ 4 Abs. 1 AAA</a>) dummy text
dummy text <a class="myclass" href="http://www.datamystic.com/__5.html"><a class="myclass" href="http://www.datamystic.com/__ 5.html">§ 5 AAA</a></a> dummy text
correct would be
dummy text <a class="myclass" href="http://www.datamystic.com/__5a.html">§ 5a AAA</a> dummy text <a class="myclass" href="http://www.datamystic.com/__5.html">§ 5 AAA</a>
dummy text dummy text (<a class="myclass" href="http://www.datamystic.com/__4.html">§ 4 Abs. 1 AAA</a>) dummy text
dummy text <a class="myclass" href="http://www.datamystic.com/__5.html">§ 5 AAA</a> dummy text
Example: If I use </.> instead of <. > I get rid of the leading space in $1 but then the second line (here: § 4 Abs. 1 AAA) is not converted. The leading space is not so important because I could thereafter use a second filter to search for "__" followed by 1 character as a number and replace it in a second step. This can probably be done by a Perl pattern style.
gerd
I guess I have to upgrade to a new version. I have Text Pipe 8.1.1 of TextpipeLite and cannot load the filter.(expecting file type <= 89, reading type:98)
Error reading TFListerList: Error reading TInputObject
To which version do I need to upgrade? TextpipeLite or Standard? Shall I do it directly at you or at your European partner "shareit" in Cologne?
If your filter in the zip file is identical with the above pattern code then there is still a problem:
Text from Trial Area in version 8.1.1.
dummy text § 5a AAA dummy text § 5 AAA
dummy text dummy text (§ 4 Abs. 1 AAA) dummy text
dummy text <a class="myclass" href="http://www.datamystic.com/__5.html">§ 5 AAA</a> dummy text
leads with §[optional space, capture(1 to 12 letter or number or <. >), 1-2 space]AAA to
dummy text <a class="myclass" href="http://www.datamystic.com/__ 5a.html">§ 5a AAA</a> dummy text <a class="myclass" href="http://www.datamystic.com/__ 5.html">§ 5 AAA</a>
dummy text dummy text (<a class="myclass" href="http://www.datamystic.com/__ 4 Abs. 1.html">§ 4 Abs. 1 AAA</a>) dummy text
dummy text <a class="myclass" href="http://www.datamystic.com/__5.html"><a class="myclass" href="http://www.datamystic.com/__ 5.html">§ 5 AAA</a></a> dummy text
correct would be
dummy text <a class="myclass" href="http://www.datamystic.com/__5a.html">§ 5a AAA</a> dummy text <a class="myclass" href="http://www.datamystic.com/__5.html">§ 5 AAA</a>
dummy text dummy text (<a class="myclass" href="http://www.datamystic.com/__4.html">§ 4 Abs. 1 AAA</a>) dummy text
dummy text <a class="myclass" href="http://www.datamystic.com/__5.html">§ 5 AAA</a> dummy text
Example: If I use </.> instead of <. > I get rid of the leading space in $1 but then the second line (here: § 4 Abs. 1 AAA) is not converted. The leading space is not so important because I could thereafter use a second filter to search for "__" followed by 1 character as a number and replace it in a second step. This can probably be done by a Perl pattern style.
gerd
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Autolinking feature with variable content
Hi Gerd,
Please login and use the secure system to guide the upgrade process - you just need to upgrade TextPipe Lite.
I did update the pattern, and it worked fine on the test data you provided earlier.
Please login and use the secure system to guide the upgrade process - you just need to upgrade TextPipe Lite.
I did update the pattern, and it worked fine on the test data you provided earlier.
Re: Autolinking feature with variable content
Hi Simon,
I have upgraded to 8.4.8 and could load the filter but the second line
dummy text (§ 4 Abs. 1 AAA) dummy text
still leads to
dummy text (<a class="myclass" href="http://www.datamystic.com/__ 4 Abs. 1.html">§ 4 Abs. 1 AAA</a>)
whereas it should be
dummy text (<a class="myclass" href="http://www.datamystic.com/__ 4.html">§ 4 Abs. 1 AAA</a>)
and
dummy text (§ 4 Abs. 1 No. 1 AAA) dummy text
should be as well
dummy text (<a class="myclass" href="http://www.datamystic.com/__ 4.html">§ 4 Abs. 1 No. 1 AAA</a>)
as described above. If you see a chance to get this done would be fine. If not I will use the Perl pattern for stuff in a link, send matching text to subfilter and use a pattern to find and replace the string
Abs.
with a leading and a following space in a URL by say XXX. I would then locate them by searching for XXX and change them manually. This is at least quite a good help for me because those files represent only around 10% of about 1500 files.
Thanks for your support.
gerd
I have upgraded to 8.4.8 and could load the filter but the second line
dummy text (§ 4 Abs. 1 AAA) dummy text
still leads to
dummy text (<a class="myclass" href="http://www.datamystic.com/__ 4 Abs. 1.html">§ 4 Abs. 1 AAA</a>)
whereas it should be
dummy text (<a class="myclass" href="http://www.datamystic.com/__ 4.html">§ 4 Abs. 1 AAA</a>)
and
dummy text (§ 4 Abs. 1 No. 1 AAA) dummy text
should be as well
dummy text (<a class="myclass" href="http://www.datamystic.com/__ 4.html">§ 4 Abs. 1 No. 1 AAA</a>)
as described above. If you see a chance to get this done would be fine. If not I will use the Perl pattern for stuff in a link, send matching text to subfilter and use a pattern to find and replace the string
Abs.
with a leading and a following space in a URL by say XXX. I would then locate them by searching for XXX and change them manually. This is at least quite a good help for me because those files represent only around 10% of about 1500 files.
Thanks for your support.
gerd
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Autolinking feature with variable content
Ah - please change the EasyPattern to:
(attached)
Code: Select all
§[longest optional space, capture( longest 1+ number), 1 to 12 alpha or number or <. >, longest 1+ space]AAA
- Attachments
-
- gerd.zip
- (724 Bytes) Downloaded 571 times
Re: Autolinking feature with variable content
Simon,
I would not believe it to make it work with Textpipe. It works exactly as requested. I thought I would need a php or perl programmer or do it manually. You are great. I looked up the easypatterns_reference.html but it is highly too complex for me.
May I suggest 2 points:
1) The Link to whatsnew.html for easypattern is wrong. It should read to http://www.datamystic.com/easypattern/whatsnew.html and not to timezomer.
2) You have so many filters embedded in Textpipe in different directories like etext, html or fun. The file description is good. Nonetheless it would be more useful and comfortable to have all of them listed in a single html file. It would save the time to go step by step through each directory and would be much more clearer. Just have them listed in a single html file with the path to the directory. Or in other words: Do you have a filter which can do that? My workaround is to just copy all of them in a special directory.
I also looked up for something like an HTML indexmaker which I couldn't find in the forum and in Textpipe itself. Example: Go through the "Files to process" and extract the contents from the title tag and produce an output like
<a title="Text from the title tag" href="link to the filename.htm?">Text from the title tag</a><br>
This is probably useful for a lot of people and not all the people can afford the cost for the php programm which does this or can program it by themselves.
Just a suggestion.
Thanks again for this great EasyPattern Code
gerd
I would not believe it to make it work with Textpipe. It works exactly as requested. I thought I would need a php or perl programmer or do it manually. You are great. I looked up the easypatterns_reference.html but it is highly too complex for me.
May I suggest 2 points:
1) The Link to whatsnew.html for easypattern is wrong. It should read to http://www.datamystic.com/easypattern/whatsnew.html and not to timezomer.
2) You have so many filters embedded in Textpipe in different directories like etext, html or fun. The file description is good. Nonetheless it would be more useful and comfortable to have all of them listed in a single html file. It would save the time to go step by step through each directory and would be much more clearer. Just have them listed in a single html file with the path to the directory. Or in other words: Do you have a filter which can do that? My workaround is to just copy all of them in a special directory.
I also looked up for something like an HTML indexmaker which I couldn't find in the forum and in Textpipe itself. Example: Go through the "Files to process" and extract the contents from the title tag and produce an output like
<a title="Text from the title tag" href="link to the filename.htm?">Text from the title tag</a><br>
This is probably useful for a lot of people and not all the people can afford the cost for the php programm which does this or can program it by themselves.
Just a suggestion.
Thanks again for this great EasyPattern Code
gerd
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Autolinking feature with variable content
Thanks Gerd
- on what web page is the incorrect link? I've had a look but can't find it
- thanks for the suggestion
- index maker attached!
- on what web page is the incorrect link? I've had a look but can't find it
- thanks for the suggestion
- index maker attached!
- Attachments
-
- index maker.zip
- (1.33 KiB) Downloaded 583 times
Re: Autolinking feature with variable content
The incorrect link is on http://www.datamystic.com/products.html
See Linktext "What's new" under the icon EasyPattern Helper. The Link leads to timezone
http://www.datamystic.com/timezone/whatsnew.html
Thanks for showing the extraction of text. It is indeed selfexplanatory and simple to understand.
gerd
See Linktext "What's new" under the icon EasyPattern Helper. The Link leads to timezone
http://www.datamystic.com/timezone/whatsnew.html
Thanks for showing the extraction of text. It is indeed selfexplanatory and simple to understand.
gerd
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Autolinking feature with variable content
Thanks Gerd - that page had not been updated for some time - have just fixed it!