キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

String to number conversion

解決済み
解決策を見る

Hi,

 

This should be simple, but I can't figure out a good conversion methout "rube-goldberging" my code.

Scan from string.png

 

As I have tried to demonstrate above I am trying to get numbers from the end of a string

 

1) The string can be any length, and contain any characters.

2) There can be any amount of other numbers in the string, these are not of interest.

3) There will always be atleast one "normal" character inforont of the number I want.

 

I have a feeling the scan from string function will do what I want, but I can't figure out the right format string I should use as a input...

 

Anyone here have any good ideas? 

0 件の賞賛
メッセージ1/10
5,975件の閲覧回数

Hi

 

what i have understood is, that you want the Numbers which are at the end of the string.

Is this what you want (see attached)

Somil Gautam
Think Weird
0 件の賞賛
メッセージ2/10
5,969件の閲覧回数

Yes, something like that is what I want, too bad it does not work 😉

 

Your code assumes that there is always one "number character" at the end of the string with known length, but both the amount of "number characters" and the length of my string is unkown... 

0 件の賞賛
メッセージ3/10
5,961件の閲覧回数
Are you sure that your string always ends with a number?
Somil Gautam
Think Weird
0 件の賞賛
メッセージ4/10
5,956件の閲覧回数
string number.png
0 件の賞賛
メッセージ5/10
5,951件の閲覧回数

Somil: yes, that is the just about the only safe assumption I can make...

 

Mathan: Close! But if there are numbers in the string that are not at the end, those numbers is what I get..

Message Edited by Jan_HeG on 10-28-2009 05:25 AM
0 件の賞賛
メッセージ6/10
5,949件の閲覧回数
解決策
受理者 Jan_HeG

Regular expressions are your friend:

 

Use [0-9]+$ as the regular expression. The dollar sign ($) will look for the match only if it are the last characters of the string.

 

Ton

Message Edited by TCPlomp on 28-10-2009 11:26 AM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
メッセージ7/10
5,944件の閲覧回数

Assuming that you have purely the digits 0-9 at the end of string, you can pre-process the strinh with "match pattern" using regular expression "[0-9]*$". This will match any number of characters chosen from the range 0 to 9 at the end of the string.

 

The match substring output is the number, so decimal string to number will then get the number into an integer.

 

Rod.

 

0 件の賞賛
メッセージ8/10
5,943件の閲覧回数

thank you, i tried so much to know string to dbl.

now i got.

0 件の賞賛
メッセージ9/10
5,131件の閲覧回数

can i convert dbl again to the string after inserting dbl in to an array.

0 件の賞賛
メッセージ10/10
4,995件の閲覧回数