Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: regex for translation

by hdb (Monsignor)
on Oct 02, 2013 at 13:31 UTC ( [id://1056611]=note: print w/replies, xml ) Need Help??


in reply to regex for translation

Not sure I really understand what you are looking for. My understanding is that your are looking for substrings like __(...) with various possible types of strings between the parentheses. I would suggest to use a regex to find these general patterns and then call a function to process (with further regexes) what's in between. It could look like this:

sub process { print shift, "\n"; } my $string = "ccc __(dddd)ccc __(eeee)ssss"; $string =~ s/__\(([^)]+)\)/process($_)/egis;

The advantage is to split the complex regex into two pieces, one applied to the larger text and then one for the template bits you have extracted. You could even call it recursively. Whether or not this makes sense or is faster, you would have to try.

Replies are listed 'Best First'.
Re^2: regex for translation
by klayman (Initiate) on Oct 02, 2013 at 16:06 UTC
    I agree. I will need to get the regular expression split at least into two as string within __(...) can contain another __(...) string. Working on the two regexes that will accomplish this. Problem is that text in the translation tags __(...) can contain any combination of ( or ) or even __ or even " and ' which am using in regex to track for translation tags __(" ... ")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1056611]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-03-28 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found