Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax for findrx/replecerx
#1
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
#2
(MD|DDS|etc)
#3
This is a simplified version of what I am trying to do

Code:
Copy      Help
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
#4
Hi All,
Didn't mean to waste anybody's time...the code I submitted above works just fine!
THanks again,
Stuart
#5
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.
#6
Macro
Code:
Copy      Help
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.
#7
str a = "Your name: Im craig234, $$: 1327.54"
a.replacerx("^.+?(\d+)$" "$1")
out a

not sure what to do tried a thing things
#8
when i run it 'a' is equal to the '1327' you were wanting :?:
what else were you wanting?
An old blog on QM coding and automation.

The Macro Hook
#9
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.
#10
replace

\d

to

[\d\.]
#11
try this.
Macro
Code:
Copy      Help
str a = "Your name: Im craig234, $$: 1327.54"
a.replacerx("^.+?(\d+)(\.\d+)$" "$1")
out a
An old blog on QM coding and automation.

The Macro Hook
#12
Thanks for your help.


Forum Jump:


Users browsing this thread: 1 Guest(s)