Posts: 1,006
Threads: 330
Joined: Mar 2007
Hi,
I would like to search a name string so that the degree is removed ", MD" or ", DDS" or ", PHD" or ", NP"
I think I can write the findrx regex string for those pretty easy -
but how do you set it up so that if it doesn't find the first one, it searches for the second one, if that fails, go to the third, etc.....
can it be setup to search for all four at once or do I have to do it serially with err statements?
Thanks so much!
Stuart
Posts: 12,072
Threads: 140
Joined: Dec 2002
Posts: 1,006
Threads: 330
Joined: Mar 2007
This is a simplified version of what I am trying to do
str md
str pattern = ", (MD|DDS|NP|PHD)"
md.replacerx(pattern "")
Whether the initial version of md is
md = "John J Doe, MD"
or
md = "John J Doe, DDS"
or
md = "John J Doe, NP"
or
md = "John J Doe, PHD"
I want the final version of md to be "John J Doe"
I am not sure why my regex is not working. Any ideas?
Stuart
Posts: 1,006
Threads: 330
Joined: Mar 2007
Hi All,
Didn't mean to waste anybody's time...the code I submitted above works just fine!
THanks again,
Stuart
Posts: 229
Threads: 22
Joined: Sep 2007
im having difficulty with regualr expression.
Im not sure exactly how to use it as of yet and have been looking through.
str a = "Your name: Im craig234, $$: 1327"
the "$$:" and "1327" will not always be in the same place depending on your name and how much.
Im trying to remove everything to the left so i have just "1327" and when the string changes i will still be able to get how much is there.
Thanks.
Posts: 12,072
Threads: 140
Joined: Dec 2002
Macro
str a = "Your name: Im craig234, $$: 1327"
a.replacerx("^.+?(\d+)$" "$1")
out a
$1 in replacement means the first enclosed part. So everything that is not enclosed is removed.
Posts: 229
Threads: 22
Joined: Sep 2007
str a = "Your name: Im craig234, $$: 1327.54"
a.replacerx("^.+?(\d+)$" "$1")
out a
not sure what to do tried a thing things
Posts: 1,769
Threads: 410
Joined: Feb 2003
when i run it 'a' is equal to the '1327' you were wanting :?:
what else were you wanting?
Posts: 229
Threads: 22
Joined: Sep 2007
craig1983 Wrote:str a = "Your name: Im craig234, $$: 1327.54"
a.replacerx("^.+?(\d+)$" "$1")
out a
not sure what to do tried a thing things
Im sorry, must have deleted my question by mistake.
the post that gin made, is excellent for me, however at times i have
str a = "Your name: Im craig234, $$: 1327.54"
and because of the decimal the result is not true.
Posts: 12,072
Threads: 140
Joined: Dec 2002
Posts: 1,769
Threads: 410
Joined: Feb 2003
try this.
Macro
str a = "Your name: Im craig234, $$: 1327.54"
a.replacerx("^.+?(\d+)(\.\d+)$" "$1")
out a
Posts: 229
Threads: 22
Joined: Sep 2007