View Single Post
Old 02-22-2013, 10:13 AM   PM User | #2
Arcticwarrio
Regular Coder

 
Arcticwarrio's Avatar
 
Join Date: May 2012
Location: UK
Posts: 624
Thanks: 16
Thanked 70 Times in 70 Posts
Arcticwarrio is on a distinguished road
PHP Code:
 <?php
  
# URL that generated this code:
  # http://txt2re.com/index-php.php3?s=slus_123.45&2&-22&3&-16&4

  
$txt='slus_123.45';

  
$re1='((?:[a-z][a-z]+))';    # Word 1
  
$re2='(_)';    # Any Single Character 1
  
$re3='(\\d+)';    # Integer Number 1
  
$re4='(\\.)';    # Any Single Character 2
  
$re5='(\\d+)';    # Integer Number 2

  
if ($c=preg_match_all ("/".$re1.$re2.$re3.$re4.$re5."/is"$txt$matches))
  {
      
$word1=strtoupper($matches[1][0]);
      
$c1=$matches[2][0];
      
$int1=$matches[3][0];
      
$c2=$matches[4][0];
      
$int2=$matches[5][0];
      print 
"$word1-$int1$int2 \n";
  }

  
#-----
  # Paste the code into a new php file. Then in Unix:
  # $ php x.php 
  #-----
?>
__________________
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.

Last edited by Arcticwarrio; 02-22-2013 at 10:19 AM..
Arcticwarrio is offline   Reply With Quote