I need to change in many SAS programs one-asterisk comments with two-asterisk comments and insert a space after the second asterisk. The comments are following a semicolon.
Example, the following line:
data a; *create data a;
shuld change into:
data a; ** create data a;
I figured out:
Find What: "; \x2a\\[:a-z:]" (without the quotes)
but I can't do the:
Replace With:
Of course, I don't want to replace 2 asterisks with 3 asterisks.
Regular expressions - Replace one asterisk with two
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
Hello boldan.....
You wrote:
Try this:
Search: \(; \*\)\([^\*]\)
Replace: \1* \2
===============================
Explanation of Regex Search Example:
\( = start of first tagged expression)
; = semicolon
= space
\* = an asterisk
\) = end of first tagged expression
\( = start of second tagged expression
[^\*] = any character execept an asterisk
\) = end of second tagged expression
Explanation of Regex Replace Example:
\1 = first tagged expression
* = asterisk
= space
\2 = second tagged expression
=============================
Common English expression: Find a string of a semicolon followed by a space followed by a single asterisk and replace that string with itself, insert an asterisk and a space, and replace the second remaining string.
I did this to look for only one * in case you already had code that had been replaced and was correct. I did not want to ruin that which was already OK.
Hope this helps..............good luck,
Bob
You wrote:
==========================
I need to change in many SAS programs one-asterisk comments with two-asterisk comments and insert a space after the second asterisk. The comments are following a semicolon.
Example, the following line:
data a; *create data a;
shuld change into:
data a; ** create data a;
Try this:
Search: \(; \*\)\([^\*]\)
Replace: \1* \2
===============================
Explanation of Regex Search Example:
\( = start of first tagged expression)
; = semicolon
= space
\* = an asterisk
\) = end of first tagged expression
\( = start of second tagged expression
[^\*] = any character execept an asterisk
\) = end of second tagged expression
Explanation of Regex Replace Example:
\1 = first tagged expression
* = asterisk
= space
\2 = second tagged expression
=============================
Common English expression: Find a string of a semicolon followed by a space followed by a single asterisk and replace that string with itself, insert an asterisk and a space, and replace the second remaining string.
I did this to look for only one * in case you already had code that had been replaced and was correct. I did not want to ruin that which was already OK.
Hope this helps..............good luck,
Bob