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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
result would be

exa = exp( cos(arg) , sin(arg) ) * fabs(arg2)+ sqrt(carg(arg3)) + sqrt(carg(arg4)*carg(arg5)+carg(arg5)*carg(arg5));

Really? Why do you go from cabsl to fabs instead of replacing it with abs? Also, your bracket counts seem to differ between the before and after examples.

Assuming that you didn't mean that and really wanted abs and the same number of brackets and correcting the arbitrary whitespace:

#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 1; my $have = 'exa=cexpl ( ccosl (arg), csinl ( arg) ) * cabsl (arg2) + c +sqrtl ( cargl(arg3)) + csqrtl(cargl(arg4) * cargl(arg5) + cargl (arg5 +) * cargl(arg5));'; my $want = 'exa = exp( cos(arg) , sin(arg) ) * abs(arg2)+ sqrt(carg(ar +g3)) + sqrt(carg(arg4)*carg(arg5)+carg(arg5)*carg(arg5));'; # Remove apparently arbitrary spaces for the purposes of validation $have =~ s/ +//g; $want =~ s/ +//g; for my $term (qw/exp cos sin abs sqrt carg/) { $have =~ s/\b[cf]? ${term} [fl]?/$term/xg; } is ($have, $want, 'Match');

In reply to Re^3: search/replace one liners without clobbering by hippo
in thread search/replace one liners without clobbering by f77coder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2021-10-22 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?