Re: interpoliation within regexp



--- "Derek B. Smith" <derekbellnersmith@xxxxxxxxx>
wrote:

I need to substitute a conversion using chr, but
have
failed on multiple attempts. Basically if the first
element contains a # then convert it. Will anyone
advise?

thank you
derek

#if first char is a-z then print it else warn
#chop string into individual characters

my @chars = unpack
("A1" x length($password),$password);

if ($chars[0] =~ /^\D/) {
print "Your new string is:\t",@chars,"\n";
}
else {
print "string starts with number, now
converting\n",
@chars, "\n";
substr($chars[0],0,1) =~
s/\Q{$chars[0]}/{chr($chars[0]}\E/;
print @chars;
}


I will try to use the /e modifier as such:

s/(\$\w+)/$1/e;

An explanation is below:
/e
Righthand side of a s/// is code to eval

/ee
Righthand side of a s/// is a string to eval, then
run as code, and its return value eval'led again.




__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
.



Relevant Pages

  • Re: [Emacs] Kommentieren
    ... ;; completely up to the user to decide, what the string ... "Chars preserved of STRING. ... `CHARS-PRESERVE' must be a parentized expression, ...
    (de.comp.editoren)
  • Re: FASTEST way to try all strings (a until ZZZZZZZZZZZZZZZZZZZZZZZZ)
    ... > It will be a very huge table so I in my opinion. ... > When it would be used, than it should be converted to a string, however ... >> How would an array of Byte be any faster then an array of Char? ... >> array of Byte is needed, however the OP suggested Chars (A to Z, a to z ...
    (microsoft.public.dotnet.languages.vb)
  • Re: FASTEST way to try all strings (a until ZZZZZZZZZZZZZZZZZZZZZZZZ)
    ... > It will be a very huge table so I in my opinion. ... > When it would be used, than it should be converted to a string, however ... >> How would an array of Byte be any faster then an array of Char? ... >> array of Byte is needed, however the OP suggested Chars (A to Z, a to z ...
    (microsoft.public.dotnet.general)
  • Re:(9corr) string
    ... and I want to remove the month in the timestamp for each of the string ... Then advance 4 chars, and copy from +2 to the current pointer until you ... pointer past the year part to reach the month part. ... this guarantee is 'memmove'. ...
    (comp.lang.c)
  • Re: speed question
    ... chars of column A and first 2 of column B. ... as it is a string contatenation. ... > I want to have smart search like iTunes or something like that. ... > Dzemal Tipura (Dzemo) - MCP ...
    (microsoft.public.dotnet.framework.adonet)