Hi. I'm not totally sure what ur asking but it seems that u want to do
variable substitution in an XML file. If the variable names are already in
the text u need an eval.
$text = eval "\"$xmlfile\"";
That will replace $1 with whatever it's current value is.
Here is the Perl code which I'm using for substitution in xml file
UIIE_A_123456.xml.
I'm getting search string and replacement string for substitution from another
file (cleanup.txt)
But after substitution, variable of replaced string doesn't interpolated as
defined in
Foo Ji-Haw <[EMAIL PROTECTED]> writes:
> I'm trying to 'water down' a utf8-encoded to latin-1. Using
> Encode::encode does the trick, and it replaces character that do not
> fit into latin-1 with a subtitution character (as per the
> documentation)
>
> Can anyone tell me how I can change this cha
Hi all,
I'm trying to 'water down' a utf8-encoded to latin-1. Using
Encode::encode does the trick, and it replaces character that do not fit
into latin-1 with a subtitution character (as per the documentation)
Can anyone tell me how I can change this character to something else,
like a ' '?
Not sure I'm getting it completely, but using match in a while loop w/ the
/g modifier lets you process a string one match at a time:
my $string = "Lots of words to be read one at a time.\nthough more than
one line";
while ( $string =~ /(\w+)/g ) {
print "Found: $1\n";
print "Proceessing ..
Joe Discenza wrote:
"Veli-Pekka Tätilä" wrote, on Sun 10/9/2005 15:58
replacement is so complex that it cannot be
expressed as a straight substitution. So I would have to find a
piece of text, process it in a separate function, and replace the
matched text with the newly computed
Kenneth McNamara wrote:
You're implying that the music macro language is pos() sensitive.
That is a pretty severe problem in itself.
Hmm, I'm not totally sure if it is. But true certain modifiers apply until
the next note, such as one or more periods. My MML experience is actually
from trying t
Title: Regex Newbie Q: Non-Trivial Substitution and Modifying the MatchedString
"Veli-Pekka Tätilä" wrote, on Sun 10/9/2005 15:58: Yet another newbie question about regular
expressions:: I'd like to find and replace bits of text as usual. However,
rather than: replace all
and replace bits of text as usual. However, rather
than replace all occurrences in one quick swoop using the s-
operator and the g-flag, the replacement is so complex that it
cannot be expressed as a straight substitution. So I would have to
find a piece of text, process it in a separate fu
So what ur saying is that u want to do a lot of substitutions in one pass.
U could always have one s///g for each thing u want substituted and run it n
times. Can u post some actual strings that u want to parse and the
substitutions? Then we can figure it out.
At 10:58 PM 10/9/05 +0300, =?iso-88
aight substitution. So I would have to find a piece of text, process it
in a separate function, and replace the matched text with the newly computed
text. This goes on for n interesting matches in the input.
Can I do this kind of thing in a simple loop, processing all matches one by
one? My understandi
On Fri, 30 May 2003, Nut Cracker wrote:
> open(MF, "MyFile.txt");
> while(defined($line=)){
> if($line =~ /\/ig){
> $line =~ s/\/\r/;
> }
> }
>
>
> it might be ugly, but it should work.
>
> NuTs
>
It's unnecessarily ugly. There's no need to esca
On Fri, 30 May 2003, Charlie Schloemer wrote:
> - Original Message -
> From: "Ricci, Mark" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, May 30, 2003 11:04 AM
> Subject: Global substitution
>
>
> > Hello All,
> >
>
On Fri, 30 May 2003, Ricci, Mark wrote:
> Hello All,
>
> I have a file that has characters instead of carriage returns.
> I'm having a hard time coming up with an automated search and replace
> script.
>
> Any ideas would be appreciated...
>
How about $data=~s//\n/gi;
[EMAIL PR
MAIL PROTECTED]>
Sent: Friday, May 30, 2003 11:04 AM
Subject: Global substitution
> Hello All,
>
> I have a file that has characters instead of carriage returns.
> I'm having a hard time coming up with an automated search and replace
> script.
>
> Any ideas would be
Er, what were you trying to do again?
Why won't { my @bits = split":",$in; } be good enough
to get the bits, and the rewriting as {print join":",@bits} ?
Sorry, little history in my box
lee
Lee Goddard, BA(Hons), MSc(Sussex)
http://www.LeeGoddard.com/ since 1997.
Direcotr: Little Bits Ltd
> Either quote the meta characters in the search string by enclosing it
> in \Q \E sequences or quote each meta separtately by preceeding
> it with a \ character, e.g.
>
> s!\Q$search\E!$replace!;
>
> or
>
> @search=split(//,$search);
> foreach $char (@search) {
> $char="\\$char" if $char=~/\W
>
> However, I cannot get the substitution to work correctly, I assume, because
> of the metacharacters in the string. A typical original string and
> replacement would be:
>
> $search = "../pdf/sax_quartet/BMP0016.pdf:BMP0016.pdf:No baile mas (Dance No
> More):Cervante
That worked perfectlythanks!
-Original Message-
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 1:42 AM
To: T&C Winquist
Cc: [EMAIL PROTECTED]
Subject: Re: substitution regular expression
T&C Winquist wrote:
> It seems like every
Dirk Bremer wrote:
> I am looking for a regex to be used for comma substitution for numbers,
i.e. the regex would transform:
>
> 999 = 999
> = 9,999
> 9 = 99,999
> 99 = 999,999
> 999 = 9,999,999, etc.
>
> I tried s/(\d
Dirk Bremer wrote:
> I am looking for a regex to be used for comma substitution for numbers, i.e. the
>regex would transform:
>
> 999 = 999
> = 9,999
> 9 = 99,999
> 99 = 999,999
> 999 = 9,999,999, etc.
>
> I tried s/(\d{3})/
TED]]
Sent: Friday, December 21, 2001 13:18
To: perl-win32-users
Subject: Regex for comma substitution
I am looking for a regex to be used for comma substitution for numbers, i.e. the regex
would transform:
999 = 999
= 9,999
9 = 99,999
99 = 999,999
999 = 9,999,
I am looking for a regex to be used for comma substitution for numbers, i.e. the regex
would transform:
999 = 999
= 9,999
9 = 99,999
99 = 999,999
999 = 9,999,999, etc.
I tried s/(\d{3})/,$1/g, but for certain numbers it leaves a leading comma, i.e.
99
Pleic <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 18, 2001 6:49 PM
Subject: Regex (and substitution) help
> Hi Perlers,
>
> I need some help with a regex I can't figure out.
>
> In short, I need to enclose all occurences of certain "label"
D]>
Sent: Monday, June 18, 2001 5:49 PM
Subject: Regex (and substitution) help
> Hi Perlers,
>
> I need some help with a regex I can't figure out.
>
> In short, I need to enclose all occurences of certain "label"
> strings in a text file into '^' m
Denis Pleic wrote:
>
> Hi Perlers,
>
> I need some help with a regex I can't figure out.
>
> In short, I need to enclose all occurences of certain "label"
> strings in a text file into '^' marks.
>
> I.e., for example:
>
> "See SAY_PLEASE_TXT and SAY_HELLO_TXT."
>
> Those string codes *alway
Hi Perlers,
I need some help with a regex I can't figure out.
In short, I need to enclose all occurences of certain "label"
strings in a text file into '^' marks.
I.e., for example:
"See SAY_PLEASE_TXT and SAY_HELLO_TXT."
Those string codes *always* come in all caps, and with *at least*
one
while (<>) {
$_ =~ s/\s$oldWord\s/\s$newWord\s/g;
print;
}
-Original Message-
From: Rex Posadas [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 03, 2001 12:42 PM
To: [EMAIL PROTECTED]
Subject: substitution on a file
Hi,
I'm trying to make substitutions in
* End of Code ***
>
>This code replaces any occurance of "Orange" so the word "MyOrange" will
>be changed to "MyApple". I would like to change this so that "Orange" is
>the only one that is replaced by the string "App
Add a check for a word boundary to the start and finish of the old word
$_ =~ s/\b$oldWord\b/$newWord/g
hth
Andy
- Original Message -
From: "Rex Posadas" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 03, 2001 11:42 AM
Subject: substitution on
Mobile => (734) 216-6875
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Rex
Posadas
Sent: Thursday, May 03, 2001 12:42 PM
To: [EMAIL PROTECTED]
Subject: substitution on a file
Hi,
I'm trying to make substitutions in a file. My substitution
On Thu, 3 May 2001, Rex Posadas wrote:
> Hi,
>
> I'm trying to make substitutions in a file. My substitution should only
> take affect on exact matches only. below is my code:
>
>
> Start of Code ***
> $oldWord = "Orange";
> $n
Hi,
I'm trying to make substitutions in a file. My substitution should only
take affect on exact matches only. below is my code:
Start of Code ***
$oldWord = "Orange";
$newWord = "Apple";
$^I=".bk";
while (<>) {
$
33 matches
Mail list logo