BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ScottBass
Rhodochrosite | Level 12

EG 6.1 M1 (6.100.0.4025) (32-bit)

 

I pasted a bunch of text from Excel (list of variable names, one per line) into EG.

 

I now want to make them comment headers for each code block.

 

So, I tried:  Cntl-H, Find text = ^, Replace with = \* , tick Regular expression search, click Replace All (or Replace in Selection).  

Error message "Cannot find the string "^" ".

 

Tried the same using the "right arrow/play button" pulldown for ^ Start of line.  Same error.

 

Also tried:  Find text = $, Replace with = ; .  Same error.

 

Workaround:  paste into Textpad, search and replace (F8), do the same thing as above, it works fine.  Paste back into EG.

 

(In Textpad, Find text = ^(.*)$, Replace text = \* \1 ; does it all in one search and replace, which is kind of cool.)

 

Can anyone comment 1) if they also experience this issue in EG 6.x, and 2) is it fixed in later releases?

 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
1 ACCEPTED SOLUTION

Accepted Solutions
CaseySmith
SAS Employee

You are actually running into two limitations of the Find/Replace dialog in the EG editor...

 

1) It doesn't currently handle zero-width regular expression matches (such as lone ^ and $).  If you use those anchors in regular expressions that return greater-than-zero-width matches, it'll find the matches just fine.

 

2) It doesn't currently allow regular expression substitutions in the replacement text.  (ex. a capture)

 

We are aware of both of these limitations (which still exist in the latest version of EG) and hope to be able to address them in a future release.

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

View solution in original post

2 REPLIES 2
ballardw
Super User

The regular expression parser in the editor seems to be only a subset of regular expressions.

Part of the issue with the search and replace in the editor is that it has to handle the non-regular expressions as well.

 

You might be able to use

Search for \n

Replace \n/*

for the start of a line

or search \n

replace */\n for end of line

 

but generally I would find the editor Ctrl-/ on a block or line of text easier.

CaseySmith
SAS Employee

You are actually running into two limitations of the Find/Replace dialog in the EG editor...

 

1) It doesn't currently handle zero-width regular expression matches (such as lone ^ and $).  If you use those anchors in regular expressions that return greater-than-zero-width matches, it'll find the matches just fine.

 

2) It doesn't currently allow regular expression substitutions in the replacement text.  (ex. a capture)

 

We are aware of both of these limitations (which still exist in the latest version of EG) and hope to be able to address them in a future release.

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 3800 views
  • 0 likes
  • 3 in conversation