Sponsored Content
Top Forums Shell Programming and Scripting find and Replace String in Perl - Regexp Post 302959300 by MadeInGermany on Saturday 31st of October 2015 08:14:01 AM
Old 10-31-2015
$repl_str contains a / that is also used as a separator.
Take another separator
's#$find_str#$repl_str#'
--
Why do you run another perl instance?
This User Gave Thanks to MadeInGermany For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find the position of a string and replace with another string

Hi, I have a file named "Test_2008_01_21" The file contains a string "manual" that occurs many times in the file How can i find the positions of the string "manual" in the file Ex: if the string " manual " occurs three times in the file. i want to replace the second occurance of string... (6 Replies)
Discussion started by: bab123
6 Replies

2. Shell Programming and Scripting

Find & Replace string in multiple files & folders using perl

find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g' this is simple logic to find and replace in multiple files & folders Hope this helps. Thanks Zaheer (0 Replies)
Discussion started by: Zaheer.mic
0 Replies

3. Shell Programming and Scripting

How to replace string in perl?

Hi, I have string like this: $query="#1,apple"; $string=$query; I want to replace #1 with fruit. I tried like this: string=~s/#\d+/$query/ig; print "\n string: $string\n"; It is working only when there is single #1 or #2 but when i give like #1,#2,#3,apple the above code... (2 Replies)
Discussion started by: vanitham
2 Replies

4. Shell Programming and Scripting

How to find the count and replace the particular part of string in perl?

Hi, I am taking the current time using localtime function in perl. For example if the time is: #Using localtime $time = "12:3:10"; I have to replace the value 3 (03) i.e second position to be 03. The output should be: 12:03:10 But if the other string for example: $str:... (1 Reply)
Discussion started by: vanitham
1 Replies

5. Shell Programming and Scripting

replace awk with a perl one liner (REGEXP and FS)

hello, I want to replace awk with a perl one liner in unix. i use in awk REGEX and FS ( field separator) because awk syntaxes in different unix os versions have not the same behaviour. Awk, Nawk and GNU Awk Cheat Sheet - good coders code, great reuse i have a file named "file" and want... (5 Replies)
Discussion started by: bora99
5 Replies

6. Shell Programming and Scripting

find string and replace with string in other file

Dear all, I need your help, I have file like this: file1:23456 01910964830098775635 34567 01942809546554654323 67589 26546854368698023653 09778 58716868568576876878 08675 86178546154065406546 08573 54165843543054354305 . .file2: 23456 25 34567 26 67589 27 (2 Replies)
Discussion started by: attila
2 Replies

7. Shell Programming and Scripting

HPUX find string in directory and filetype and replace string

Hi, Here's my dilemma. I need to replace the string Sept_2012 to Oct_2012 in all *config.py files within the current directory and below directories Is this possible? Also I am trying to find all instances of the string Sept_2012 within files in the current directory and below I have... (13 Replies)
Discussion started by: pure_jax
13 Replies

8. Solaris

How to find and replace a string?

Dear All I need to find and replace a string in a set of files. I try as : #find / -name "*"|xargs grep "Tektra"|grep -v "Tektra GSM BTS" But it doesn't work. It just finds the string in the files. I need to find and replace it.Can you please let me know how to correct it? Thank you (2 Replies)
Discussion started by: hadimotamedi
2 Replies

9. Shell Programming and Scripting

How to use regexp to find an ipaddress from a query string?

I need help with a regexp to find out the ip address which can possibly be present in a URL. The URLs can be in any of the following form <domain>?a=12345&d=somestring1 <domain>?c=10.10.10.100&d=somestring1 <domain>?a=12345&b=somestring1&c=10.1.2.4d=somestring2... (3 Replies)
Discussion started by: ampak
3 Replies

10. Shell Programming and Scripting

Perl script to read string from file#1 and find/replace in file#2

Hello Forum. I have a file called abc.sed with the following commands; s/1/one/g s/2/two/g ... I also have a second file called abc.dat and would like to substitute all occurrences of "1 with one", "2 with two", etc and create a new file called abc_new.dat sed -f abc.sed abc.dat >... (10 Replies)
Discussion started by: pchang
10 Replies
PPIx::Regexp::Dumper(3) 				User Contributed Perl Documentation				   PPIx::Regexp::Dumper(3)

NAME
PPIx::Regexp::Dumper - Dump the results of parsing regular expressions SYNOPSIS
use PPIx::Regexp::Dumper; PPIx::Regexp::Dumper->new( 'qr{foo}smx' ) ->print(); INHERITANCE
"PPIx::Regexp::Dumper" is a PPIx::Regexp::Support. "PPIx::Regexp::Dumper" has no descendants. DESCRIPTION
This class generates a formatted dump of a PPIx::Regexp::Element object (or any subclass thereof), a PPIx::Regexp::Tokenizer object, or a string that can be made into one of these. METHODS
This class provides the following public methods. Methods not documented here are private, and unsupported in the sense that the author reserves the right to change or remove them without notice. new my $dumper = PPIx::Regexp::Dumper->new( '/foo/', ordinal => 1, ); This static method instantiates the dumper. It takes the string, PPI::Element, PPIx::Regexp::Element, or PPIx::Regexp::Tokenizer to be dumped as the first argument. Optional further arguments may be passed as name/value pairs. The following options are recognized: default_modifiers array_reference This argument is a reference to a list of default modifiers to be applied to the statement being parsed. See PPIx::Regexp new() for the details. encoding name This argument is the name of the encoding of the regular expression. If specified, it is passed through to PPIx::Regexp->new(). It also causes an "Encode::encode" to be done on any parse content dumped. indent number This argument is the number of additional spaces to indent each level of the parse hierarchy. This is ignored if either the "test" or "tokens" argument is true. The default is 2. margin number This is the number of spaces to indent the top level of the parse hierarchy. This is ignored if the "test" argument is true. The default is zero. ordinal boolean If true, this option causes the "ordinal" values of PPIx::Regexp::Token::Literal objects to be dumped. perl_version boolean If true, this option causes the "perl_version_introduced" and "perl_version_removed" values associated with each object dumped to be displayed. significant boolean If true, this option causes only significant elements to be dumped. The default is false. test boolean If true, this option causes the output to be formatted as a regression test rather than as a straight dump. The output produced by asserting this option is explicitly undocumented, in the sense that the author reserves the right to change the generated output without notice of any kind. The default is false. tokens boolean If true, this option causes a dump of tokenizer output rather than of a full parse of the regular expression. This is forced true if the dump is of a PPIx::Regexp::Tokenizer. The default is false. trace number If greater than zero, this option causes a trace of the parse. This option is unsupported in the sense that the author reserves the right to change it without notice. The default is zero. verbose number If greater than zero, this option causes additional information to be given about the elements found. This option is unsupported in the sense that the author reserves the right to change it without notice. The default is zero. If the thing to be dumped was a string, unrecognized arguments are passed to "PPIx::Regexp::Tokenizer->new()". Otherwise they are ignored. list print map { "$_ " } $dumper->list(); This method produces an array containing the dump output, one line per element. The output has no left margin applied, and no newlines. print $dumper->print(); This method simply prints the result of "string" to standard out. string print $dumper->string(); This method adds left margin and newlines to the output of "list", concatenates the result into a single string, and returns that string. SUPPORT
Support is by the author. Please file bug reports at <http://rt.cpan.org>, or in electronic mail to the author. AUTHOR
Thomas R. Wyant, III wyant at cpan dot org COPYRIGHT AND LICENSE
Copyright (C) 2009-2013 by Thomas R. Wyant, III This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. perl v5.16.3 2014-06-10 PPIx::Regexp::Dumper(3)
All times are GMT -4. The time now is 07:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy