Sign in to follow this  
Followers 0
EvAsion

StringRegExpReplace query.

4 posts in this topic

#1 ·  Posted (edited)

OK, i have a string like this 'H24O18C19'

How can i put a comma between 'the end of a series of numbers' and a letter

so: 'H24,O18,C19'

i was thinking something like this.

$string = "H24O18C19"
$replace = StringRegExpReplace($string, "\d(\w)*?",",")
msgbox(0,"",$replace)

Edit: see bottom post.

Edited by EvAsion

Share this post


Link to post
Share on other sites

$string = "H24O18C19"
$replace = StringRegExpReplace($string, "\w\d+","\0,")
msgbox(0,"",StringTrimRight($replace, 1))


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Oh and one more thing If i have 2 capital letters next to each other, or a noncapital next to a capital, how can i put a 1 between them(or if i have a capital letter then white space or nothing, put a 1 after the capital letter)? So 'HeHP' becomes 'He1H1P1'

How can i put a , in a string like 'He232' between the end of the letters and the start of the numbers (becoming 'He,232'), regardless of how many letters/numbers there are on each side?

Edited by EvAsion

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0