Cancel
Showing results for 
Search instead for 
Did you mean: 

Find a "." in a string

Creator
Creator

Hello everyboy,
I'm facing the issue that I'm not able to find a "." in a string.

 

------------------------------------------------------------------
var a :string := "6.100,2"
var res: any

 

--neither
res:= pos(a, ".")
print res

 

--nor
res:= print regex_search(a, ".")  -- "dot" is a variable used for any char, so it's obvious to me that this does not work.
print res
--are working

 

--replacing works
res:= regex_replace(a, ",", ".") = "6.100.2"
print res
-----------------------------------------------------------------

 

has anybody faced the same issue so far?

 

Best regards
Joge

6 REPLIES

Re: Find a "." in a string

Phenom
Phenom
For alignment :

what Plant Simulation version are you using , including update version ?

Re: Find a "." in a string

Creator
Creator

I'm using 13.1.1.1053

Re: Find a "." in a string

Phenom
Phenom

have you tried pos with swapped parameters ?

 

e.g.  res :=pos(".",a)

 

 

Re: Find a "." in a string

Creator
Creator

outch.

 

I need to read better.

thank you very much!

Re: Find a "." in a string

Phenom
Phenom

no problem :-)

 

this can easily happen, as both parameters are strings.

 

So the system cannot distinguish , which is which.

 

 After testing it with different versions, I also had a second look in the help file

 

to find out which parameter is which.

Re: Find a "." in a string

Creator
Creator

I guess I was a little confused because in the regex_search you have the input string at first and the search string as second parameter.
It would be nice to have that in the same order.