Re: substition in perl
Bart Van der Donck wrote:
dennisha...@xxxxxxxxx wrote:
s/PATTERN/REPLALCEMENT/
and explains that the operator searches a string for PATTERN and
replaces that match with the REPLACEMENT text.
My question then is this. What string is being searched? The
documention goes on to say that if no string is specified, the $_
variable is search.
PATTERN is searched and replaced by REPLACEMENT.
No. PATTERN is what's being searched for. $_ (or whatever variable is
bound do the s///) is what's being searched. Very different.
Paul Lalli
.
Relevant Pages
- Re: [PHP] ereg_replace with user defined function?
... With a preg_replace_callback I am able to look for a pattern like: a number followed by whitespace followed by one, two, three or more characters, followed by a closing character. ... In that function I evaluate the unit, see if it is in my array containing the conversion "table". ... The metric / imperial calculations / replacements take between 0.00054 and 0.005 seconds per table cell / text string. ... replacement with preg_replace_callback compared to the function I wrote? ... (php.general) - multiple pattern replacement using regular expressions
... I needed to write an efficient pattern replacement class which could use ... Replaces multiple patterns within given string based on regular ... @param pattern a simple string or a regular expression ... (comp.lang.java.programmer) - Re: Replace strings in a text file and get the number ofreplacementsmade
... I haven't tried, but I assume Regex would find 2 matches, while replace will replace just once the pattern. ... The regex will also be expensive, because it will have to be parsed/compiled every time a new pattern is used (and if it is a user defined replacement, that would be more often than not). ... I'd opt for an extention method on string and write an efficient version of a Replace method that returns the number of matches. ... If you simply call StringBuilder.Replace(string, string, int, int) ... (microsoft.public.dotnet.languages.csharp) - Re: substition in perl
... The documentation shows the syntax as ... What string is being searched? ... PATTERN is searched and replaced by REPLACEMENT. ... (comp.lang.perl.misc) - Re: Predicting the Future and Kolmogorov Complexity
... Predictability is based on the pattern itself. ... addition to the string. ... For any prediction scheme, there are computable strings that show no ... Out of this hole comes a ~2 cm blue marble followed by a red ... (talk.origins) |
|