Jump to content
  • 0
botka4aet

String -> Number

Question

So i have strings "Test1", "Test2", "Test3", "Test4" and so on.

Any way to get integer from it? 1,2,3,4

Without

if (a = "Test1") b := 1;
else if (......

 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 1

there's a few different ways:
 

.@num = charat("Test3", 4);
sscanf("Test3", "Test%d", .@num);
.@num = substr("Test3", 4, 4);
pcre_match("Test3", "^[^0-9]*([0-9]+)$");
.@num = $@regexmatch$[1];

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.