Jump to content

StringRegExpReplace query.


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...