| It is trivial to do as the hard work has been done for you
Care to elaborate?
| what kind of "hell hole" are you working for that they want you to do this
I have regexes in Perl that I want to export to JavaScript, PHP, and Ruby. At least JS doesn't support the /x modifier.
| [reply] |
Care to elaborate? Hehe, ok
In this serialization they show as " ", #" ",
but in the wx gui you can see these are merely PPIx::Regexp::Token::Whitespace=HASH(0x178d3f4)
So all you do is walk the tree and delete/remove stuff you dont want,
when done serialize and what you're left is the non /x version
html explanation
Here is text version from the gui it also shows xRe::Token::Comment
So here is where you'd start, pluck out the whitespace from this tree
Maybe use Data::Diver ( data diver )
Or maybe just copy http://search.cpan.org/perldoc/PPIx::Regexp::Node#find
and use the GUI is for interactive visualization.
$ perl -MPPIx::Regexp -MData::Dump -le " $r=PPIx::Regexp->new(q{s{ \d+
+ \w+ }{}gx}); dd( $r ); print $r->content; "
bless({
children => [
bless({ content => "s" }, "PPIx::Regexp::Token::Structure"),
bless({
children => [
bless({ content => "\\d" }, "PPIx::Regexp::Token::CharClass::S
+imple"),
bless({ content => "+" }, "PPIx::Regexp::Token::Quantifier"),
bless({ content => " ", perl_version_introduced => "5.000" },
+"PPIx::Regexp::Token::Whitespace"),
bless({ content => " ", perl_version_introduced => "5.000" },
+"PPIx::Regexp::Token::Whitespace"),
bless({ content => " ", perl_version_introduced => "5.000" },
+"PPIx::Regexp::Token::Whitespace"),
bless({ content => " ", perl_version_introduced => "5.000" },
+"PPIx::Regexp::Token::Whitespace"),
bless({ content => "\\w" }, "PPIx::Regexp::Token::CharClass::S
+imple"),
bless({ content => "+" }, "PPIx::Regexp::Token::Quantifier"),
bless({ content => " ", perl_version_introduced => "5.000" },
+"PPIx::Regexp::Token::Whitespace"),
],
finish => [bless({ content => "}" }, "PPIx::Regexp::Token::Delim
+iter")],
max_capture_number => 0,
start => [
bless({ content => "{" }, "PPIx::Regexp::Token::Delimiter"),
bless({ content => " ", perl_version_introduced => "5.000" },
+"PPIx::Regexp::Token::Whitespace"),
],
type => [],
}, "PPIx::Regexp::Structure::Regexp"),
bless({
children => [],
finish => [bless({ content => "}" }, "PPIx::Regexp::Token::Del
+imiter")],
start => [bless({ content => "{" }, "PPIx::Regexp::Token::Del
+imiter")],
type => [],
}, "PPIx::Regexp::Structure::Replacement"),
bless({ content => "gx", modifiers => { g => 1, x => 1 } }, "PPIx:
+:Regexp::Token::Modifier"),
],
effective_modifiers => { g => 1, x => 1 },
failures => 0,
source => "s{ \\d+ \\w+ }{}gx",
}, "PPIx::Regexp")
s{ \d+ \w+ }{}gx
| [reply] [d/l] [select] |