Regex usage question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Regex usage question

Pharo Smalltalk Users mailing list
Hi All. Nice work on Pharo! 

We are starting to use the Regex pattern matching by allowing users to write "rules" using patterns. For example, our data lookup processing can include a 'Per' rule that takes a key such as 'xPerY' and returns the value of (data at: #x) / (data at: #y). Until recently, all binary-operators such as Per were performed with a simple string matches. But in order to generalize, we are moving regex patterns.

Can someone tell me where the language-spec is for Regex-Core that is included in Pharo? Is this in the style of sed, awk, or ... ? If possible, how do I indicated that I want several sub-string replacement sections?

Thanks in advance.
-Cam
Reply | Threaded
Open this post in threaded view
|

Re: Regex usage question

Pharo Smalltalk Users mailing list
Ah! I found the RxParser class methods for syntax and usage. I missed these previously -- my apologies.

On Tue, Jan 26, 2016 at 12:40 PM, Cameron Sanders <[hidden email]> wrote:
Hi All. Nice work on Pharo! 

We are starting to use the Regex pattern matching by allowing users to write "rules" using patterns. For example, our data lookup processing can include a 'Per' rule that takes a key such as 'xPerY' and returns the value of (data at: #x) / (data at: #y). Until recently, all binary-operators such as Per were performed with a simple string matches. But in order to generalize, we are moving regex patterns.

Can someone tell me where the language-spec is for Regex-Core that is included in Pharo? Is this in the style of sed, awk, or ... ? If possible, how do I indicated that I want several sub-string replacement sections?

Thanks in advance.
-Cam

Reply | Threaded
Open this post in threaded view
|

Re: Regex usage question

kilon.alios
Nope you should not apologize , you are not expected to read class comments before asking questions here.

You will find a dedicate chapter on regex on Deep Into Pharo which you can download as free PDFs from the Pharo website.

Pharo regex is very similar to other languages , AFAIK it's nothing special. I used it for language parsing from Pharo to Python syntax. But if you really want to do some complex parsing I highly recommend powerful parser like SmaCC and PettitParser , the good news is that they use syntax very similar to regex but far more readable, flexible and powerful. I used SmaCC which comes with good documentation and ton of examples , I think PettitParser is similar story.
On Tue, 26 Jan 2016 at 19:53, Cameron Sanders via Pharo-users <[hidden email]> wrote:
Ah! I found the RxParser class methods for syntax and usage. I missed these previously -- my apologies.

On Tue, Jan 26, 2016 at 12:40 PM, Cameron Sanders <[hidden email]> wrote:
Hi All. Nice work on Pharo! 

We are starting to use the Regex pattern matching by allowing users to write "rules" using patterns. For example, our data lookup processing can include a 'Per' rule that takes a key such as 'xPerY' and returns the value of (data at: #x) / (data at: #y). Until recently, all binary-operators such as Per were performed with a simple string matches. But in order to generalize, we are moving regex patterns.

Can someone tell me where the language-spec is for Regex-Core that is included in Pharo? Is this in the style of sed, awk, or ... ? If possible, how do I indicated that I want several sub-string replacement sections?

Thanks in advance.
-Cam