Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Regex or Normal Replace?

by Lejocode (Novice)
on Apr 17, 2017 at 01:41 UTC ( [id://1188074]=perlquestion: print w/replies, xml ) Need Help??

Lejocode has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

A quick question, if i have a large normal replace list, something like 50,000. and can be shorten to 10,000 with regex.

Which method would be the faster?
#EDIT

sorry for prior unclear briefing, here's an example:

"efg" is a word, and can be precedented by "ab" or "cd" or both, and it is still the same word. and i need to deal with it on word boundaries as it can be a part of another words. so i can use:

1- regex:
s/\b(ab)*(cd)*efg\b/$1$2exg/g;

2- normal replace:
s/\babcdefg\b/abcdexg/g; s/\babefg\b/abexg/g; s/\bcdefg\b/cdexg/g; s/\befg\b/exg/g;
i know that might seems weird to you, but in my language, it doesn't. so with large list of words like "efg", the question is:

"Which method would be the faster?"

Replies are listed 'Best First'.
Re: Regex or Normal Replace?
by Anonymous Monk on Apr 17, 2017 at 03:55 UTC
      Thanks for referring me to that post. it's helpful.
Re: Regex or Normal Replace?
by AnomalousMonk (Archbishop) on Apr 17, 2017 at 02:18 UTC
Re: Regex or Normal Replace?
by LanX (Saint) on Apr 17, 2017 at 01:44 UTC
    Quick answer: It depends.

    You didn't provide enough information about the nature of the data and the desired outcome.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re: Regex or Normal Replace?
by 1nickt (Canon) on Apr 17, 2017 at 01:44 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-04-19 08:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found