LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string regex format

I am stuck....trying to get the input numbers "1" and "0.23" into a string format result as "1:23",but instead I get a result of "1:0.23". getting rid of the "0." from the fractional number....

result string.png

 

it must be my regex expression, can this be manipulated using regex without using extra functions? appreciate all the help this forum has given....  Smiley Happy

0 Kudos
Message 1 of 8
(2,693 Views)

I don't see where you are using a regex.  I see you using a format into string.

 

Why don't you just multiply the second number by 100 and format that into the string as %0.f;%0.f  ?

Message 2 of 8
(2,684 Views)

@RavensFan wrote:

I don't see where you are using a regex.  I see you using a format into string.

 

Why don't you just multiply the second number by 100 and format that into the string as %0.f;%0.f  ?


well...the string format is time based. Meaning if the fraction is less than 10, I need the "09" (width of 2) to be inplace and not "9" for the seconds. You made a good point in my use of a format function, when I wanted a regex function?

0 Kudos
Message 3 of 8
(2,681 Views)

Apok,

Just do the math to get the "Time" elements to seconds and format into string as relative time (using the %<xxx>T specifiers)


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 8
(2,676 Views)

@apok wrote:

@RavensFan wrote:

I don't see where you are using a regex.  I see you using a format into string.

 

Why don't you just multiply the second number by 100 and format that into the string as %0.f;%0.f  ?


well...the string format is time based. Meaning if the fraction is less than 10, I need the "09" (width of 2) to be inplace and not "9" for the seconds. You made a good point in my use of a format function, when I wanted a regex function?



I don't know which you actually want, I'm just commenting on what you are actually using versus what you say you are using.

 

If the two values are integers, then I would use %d as the format specifier.  If you want it to be a width of 2 padded with zeroes, then it would be %02d.  So I think you actually want "%d:%02d" as your format specifier.  But you can work all that out if you right click the Format into String function and pick Edit Format String.

Message 5 of 8
(2,671 Views)

@ Raven: thanks, that works....

 

@Jeff: Im confused...the input number does come in as total seconds, but trying to put that into a string as "M: SS". Can you illustrate your code in time format?

0 Kudos
Message 6 of 8
(2,665 Views)

%<%M:%S>t  for relative time in MM:SS

 

Use the format property page in advanced editing mode on a timestamp constant to play with time container format specifiers (the LabVIEW Help also contains the info but the prop page is a great place to play around and get a feel for those beasties)

 

This shows hours as well:

!0.png


"Should be" isn't "Is" -Jay
Message 7 of 8
(2,656 Views)

i used both (Raven and Jeff) of your solutions in different parts of my code, MANY THANKS!...i wish i could make a 2 choice solution pick.   Smiley Wink

 

btw, my bad understanding..this was not a regex issue as Raven had pointed out "kudos"

0 Kudos
Message 8 of 8
(2,646 Views)