Rule-based placement with regular expressions

35 views
Skip to first unread message

Alex Koolhof

unread,
Jan 8, 2016, 8:40:13 PM1/8/16
to felix...@googlegroups.com
Hi folks,

Has anyone successfully created some rules with regular expressions to use with Felix's rule manager? In particular, I would like to be able replace Japanese figures automatically, which means moving the decimal point one place in the case of 億. I have used the following example in the Felix manual to successfully achieve this:

For example, 5878億 becomes 587.8 billion

However, I can't seem to get it to work when numbers contain a comma, like 5,878億. Ideally, I want the comma removed, so this too becomes 587.8 billion.

Anyone have the knowledge of regular expressions to achieve this?

I would also be interested in other useful J to E matches/replacements using regular expressions that could be imported into the rule manager if others are willing to share them?

This blog post was informative, but I still lack the knowledge of regular expressions to create my own:

Thanks

Alex 

Ryan Ginstrom

unread,
Jan 9, 2016, 3:17:19 PM1/9/16
to felix...@googlegroups.com
> On Behalf Of Alex Koolhof
> For example, 5878億 becomes 587.8 billion
>
> However, I can't seem to get it to work when numbers contain a comma, like
> 5,878億. Ideally, I want the comma removed, so this too becomes 587.8 billion.

Here is a regular expression that works for "5,878億" and "5878億":

Source:
(\d),?(\d\d)(\d)億

Target:
\1\2.\3 billion

[,?] means "optionally, a comma"

> I would also be interested in other useful J to E matches/replacements using
> regular expressions that could be imported into the rule manager if others are
> willing to share them?

I have a few that I use, but they're pretty specific to software, so I don't know how generally useful they are. If you post some patterns that you'd like to turn into rules, I'm sure I or someone else can help you out.

Regular expressions are really complicated, but they can also be useful in a lot of situations. If you've got the time to invest, the book "Mastering Regular Expressions" by Jeffrey Friedl is pretty much the bible on the subject.

Regards,
Ryan



Alex Koolhof

unread,
Jan 9, 2016, 8:38:53 PM1/9/16
to felix...@googlegroups.com
Awesome....thanks so much Ryan! Based on that rule, I'll see if I can create a few rules for figures with only two or three digits. Or perhaps I can use the "+" symbol to designate any number of digits?

Also, is there a way to have the rule match both half-width and full-width characters? The rule you provided would not match full-width.

Thanks again for your help.

Alex




--
You received this message because you are subscribed to the Google Groups "felix-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to felix-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages