I am trying to do a regular expression subsitution to captalise a list of acronyms (when they are not part of another word) with the following action:
[#0 ]
T=4
F=_TAG
1=(^|[^a-zA-Zds])(xxx|yyy|zzz)([^a-zA-Zds]|$)
2=$1$upper($2)$3
3=0
but, for example, xxx/yyy/zzz becomes XXX/yyy/ZZZ but I want XXX/YYY/ZZZ.
Alternate 'matches' are skipped.
Does anyone know a way of achieveing this?
When I put your example and expression into the tag-tag converter like this:
$regexp('xxx/yyy/zzz','(^|[^a-zA-Zds])(xxx|yyy|zzz)([^a-zA-Zds]|$)',$1$upper($2)$3)
the result is
xxx/yyy/zzz
which I think means that there is no match at all.
on the other hand
$regexp('xxx/yyy/zzz','(^.*$)',\u\u$1)
produces
"XXX/YYY/ZZZ"
MillmoorRon:
I am trying to do a regular expression subsitution to captalise a list of acronyms (when they are not part of another word) with the following action:
[#0 ]
T=4
F=_TAG
1=(^|[^a-zA-Zds])(xxx|yyy|zzz)([^a-zA-Zds]|$)
2=$1$upper($2)$3
3=0
but, for example, xxx/yyy/zzz becomes XXX/yyy/ZZZ but I want XXX/YYY/ZZZ.
Alternate 'matches' are skipped.
Does anyone know a way of achieveing this?
This worked for me:
Action type: Replace with regular expression
Field: _TAG
Regular expression: (^|[^A-Z])(xxx|yyy|zzz)([^A-Z]|$)
Replace matches with: $1$upper($2)$3
[ ] case-sensitive comparison
You don't need any of those lower-case letters in the classes when case-sensitive is unchecked. The inclusion of "ds" is puzzling since it is included in "a-z". You might try this simplified RegEx that might work depending on what your word boundaries are:
Action type: Replace with regular expression
Field: _TAG
Regular expression: \b(xxx|yyy|zzz)\b
Replace matches with: $upper($1)
[ ] case-sensitive comparison
The simple version has the added advantage that you can include acronyms with numbers like "y2k"->"Y2K" without adding them to your classes.
Sorry, it was a "replace with regular expression" Action I was doing.
Rijkstra:
This worked for me:
Action type: Replace with regular expression
Field: _TAG
Regular expression: (^|[^A-Z])(xxx|yyy|zzz)([^A-Z]|$)
Replace matches with: $1$upper($2)$3
[ ] case-sensitive comparison
You don't need any of those lower-case letters in the classes when case-sensitive is unchecked. The inclusion of "ds" is puzzling since it is included in "a-z".
I didn't think of that! The 'ds' was a typo left over from many edits!
Rijkstra:
You might try this simplified RegEx that might work depending on what your word boundaries are:
Action type: Replace with regular expression
Field: _TAG
Regular expression: \b(xxx|yyy|zzz)\b
Replace matches with: $upper($1)
[ ] case-sensitive comparison
The simple version has the added advantage that you can include acronyms with numbers like "y2k"->"Y2K" without adding them to your classes.
That seems to do the job!
Thanks all.
I know.
Yet, you can use the Tag-Tag-Converter plus the $regexp-command to test a regular expression as you get a preview.