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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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