|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Hi, I have a string like:
64.52.26.230:6355,103359,26905,97.28 I want to cut this down to: 64.52.26.230:6355 Basically I want to take all characters up to the first comma and assign this new string to a variable called $server. Can anyone tell me how to do this? [This message has been edited by scream (edited August 25, 2000).] |
|
#2
|
|||
|
|||
|
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$var =~ /^([^,]+)/; $server = $1; [/code] |
|
#3
|
|||
|
|||
|
I have been working on this regular expression and come up with this:
$server = "64.52.26.230:6355,103359,26905,97.28"; if ($server =~ /.*?,/) { print "worksn"; } I guess my regex is /.*?,/ which matches everything up to the first comma. How do I take this regex and make it assign everything up the the first comma to a variable? |
|
#4
|
|||
|
|||
|
Thanks, I ended up with
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> $var = "64.52.26.230:6355,103359,26905,97.28"; $var =~ /^([^,]+)/; $server = $1; print "$servern"; [/code] |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > regular expression help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|