Training, Open Source
computer languages


PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
any option other than substr

Posted by kitwalker2886 (kitwalker2886), 11 May 2007
if i want to cut and retrieve a string between any teo symbols.. do i ve any option other than using substr. cos i need to use index to calculate the posn if i wanna use substr..

Posted by admin (Graham Ellis), 11 May 2007
Here's a possible solution:

earth-wind-and-fire:~/may07 grahamellis$ cat retwo
$string = "Look-between-hyphens";
($inbet) = $string =~ /-(.*)-/;
print "$inbet\n";
earth-wind-and-fire:~/may07 grahamellis$ perl retwo
between
earth-wind-and-fire:~/may07 grahamellis$



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.


WELL HOUSE CONSULTANTS LTD.: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho