Suppose that variable x1 has value "123-". That is, x1 = "123-". If I use prxparse("/\ddd-/") and prxmatch I can return position 1 for this value. Now, if I didn't know ("/\ddd-/"), would there be a way for me to obtain ("/\ddd-/") from "123-"? That's, is there a way to obtain the perl regular expressions for any entry?
Thanks
Hello @banksider,
@banksider wrote:
(...) x1 = "123-". If I use prxparse("/\ddd-/") and prxmatch I can return position 1 for this value.
You mean "/\d\d\d-/", right?
Now, if I didn't know ("/\ddd-/"), would there be a way for me to obtain ("/\ddd-/") from "123-"?
The first thing I virtually always do to obtain a regular expression is to open the Tables of Perl Regular Expression (PRX) Metacharacters.
That's, is there a way to obtain the perl regular expressions for any entry?
I don't think there's an automated way to obtain "the" regex for any entry, simply because it is not unique: In your example there is a variety of matching regular expressions (depending on the purpose) ranging from very specific expressions such as "/123-/" to very general expressions like "/.*/". You may want to choose "/\d\d\d-/" for your purposes, but others would prefer, e.g., "/\w{3}?-/" for their purposes.
Hello @banksider,
@banksider wrote:
(...) x1 = "123-". If I use prxparse("/\ddd-/") and prxmatch I can return position 1 for this value.
You mean "/\d\d\d-/", right?
Now, if I didn't know ("/\ddd-/"), would there be a way for me to obtain ("/\ddd-/") from "123-"?
The first thing I virtually always do to obtain a regular expression is to open the Tables of Perl Regular Expression (PRX) Metacharacters.
That's, is there a way to obtain the perl regular expressions for any entry?
I don't think there's an automated way to obtain "the" regex for any entry, simply because it is not unique: In your example there is a variety of matching regular expressions (depending on the purpose) ranging from very specific expressions such as "/123-/" to very general expressions like "/.*/". You may want to choose "/\d\d\d-/" for your purposes, but others would prefer, e.g., "/\w{3}?-/" for their purposes.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: