svnipp has asked for the wisdom of the Perl Monks concerning the following question:
This is a very simple problem, and I feel pretty stupid asking. I have tried working thru this by reading the Regular Expression tutorial Perl doc, but I'm missing something here...
What I need to to match three characters from the middle of a string. For instance, the string 23D78000, I need to simply extract the D78 to input into a database table. My only stumbling point is the actual regexp match. Here is the latest of several things I have tried. Please don't hurt yourselves laughing...
$inq = "23D78000"; ($junk, $emc_device, $junk1) = ($inq =~ /(\w\w)(\w\w\w*$/);
Code tags and formatting added by GrandFather
2006-07-22 Retitled by Arunbear, as per Monastery guidelines
Original title: 'Simple regex matching problem...'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Match and extract three characters from the middle of a string
by ikegami (Patriarch) on Jul 21, 2006 at 19:48 UTC | |
|
Re: Match and extract three characters from the middle of a string
by chargrill (Parson) on Jul 21, 2006 at 19:49 UTC | |
|
Re: Match and extract three characters from the middle of a string
by neilwatson (Priest) on Jul 21, 2006 at 19:41 UTC | |
|
Re: Match and extract three characters from the middle of a string
by planetscape (Chancellor) on Jul 22, 2006 at 02:19 UTC | |
|
Re: Match and extract three characters from the middle of a string
by perlsen (Chaplain) on Jul 22, 2006 at 03:30 UTC | |
|
Re: Match and extract three characters from the middle of a string
by rsriram (Hermit) on Jul 22, 2006 at 06:14 UTC | |
|
Re: Match and extract three characters from the middle of a string
by sh1tn (Priest) on Jul 22, 2006 at 10:34 UTC | |
|
Re: Match and extract three characters from the middle of a string
by Leviathan (Scribe) on Jul 22, 2006 at 13:26 UTC |