473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to split string which not having spaces or etc.

250 100+
I want to split a string which not having spaces or etc. Ex:START44.98. It always having "START" and values is different.ex:00.00, 000.00,0.00. I want to take only the numeric value. How can i do that. I can't use split. Because value will vary.
This is what i have done so far.

[PHP]
$mn=split(" ",$message);//start33.33 06-08-2008 15:02 1Stop
$mnn = $mn[0];//start33.33
[/PHP]
Aug 6 '08 #1
1 1246
nathj
938 Expert 512MB
If you have the string "START123.456" and you want 123.456 out as a numeric value the following code will do just that.

[PHP]
$lcVar = "START123.456";
$lcNum = str_replace("START", "", $lcVar) ;
$lnNum = floatVal($lcNum) ;
echo $lnNum;
[/PHP]

Alternatively you could use
[PHP]
$lcVar = "START123.456";
$lcNum = substr($lcVar, 5) ;
$lnNum = floatVal($lcNum) ;
echo $lnNum;
[/PHP]

There are many more solutions, some more complicated and some more thorough but if the format is guaranteed then the above offerings should work for you.

Cheers
nathj
Aug 6 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
5
by: Robert Oschler | last post by:
Hello, Given the following program: -------------- import re x = "The dog ran. The cat eats! The bird flies? Done." l = re.split("", x)
2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
2
by: mehul | last post by:
hi all, i am just starting with PERL and had this doubt related to the speical operator +. what it says is that in the line split( / +/,$line); it will not ignore the initial spaces as it starts...
4
by: dchan1 | last post by:
String line = " I am new to c# "; How to use Regex to split the string so that It would return a String array with: token = "I" token = "am" token = "new" token =...
3
by: John Salerno | last post by:
This is an example in the book I'm reading: string fullName = " Edward C Koop "; fullName = fullName.Trim(); string names = fullName.Split(' '); string firstName = names; //...
2
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I have a string containing this information: Including file: Myfile.fle (C:\Program Files\Application\Source\Myfile.fle) After myfile.fle there are three spaces! Since i use the...
10
by: teddyber | last post by:
Hello, first i'm a newbie to python (but i searched the Internet i swear). i'm looking for some way to split up a string into a list of pairs 'key=value'. This code should be able to handle this...
2
by: ghjk | last post by:
I want to split a string which is having two space. I'm using php. ex: test test2 (between test and test2 have two spaces). Could someone help me?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.