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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.