replacing text in a string
Posted: Mon Aug 10, 2015 12:30 pm
Hi,
Could someone help me understand why I'm failing at this?
I have a string with these contents:
_GDP_STUFF_158
_GDP_STUFF_20
_CPI_STUFF_120
_CPI_STUFF_1
I'd like to make a new string consisting only of two elements: "_GDP_STUFF_" and "_CPI_STUFF_". My strategy was to use @wreplace to replace the numbers with nonsense that I would then use @wdrop to get rid of, and then use @wunique to get me only unique elements.
If anyone has a more elegant way they've done something similar, please let me know. But outside of that, I am failing trying to get @wreplace to work.
Assuming the name of mu string is "stringname," I am trying things like:
string stringname=@wreplace(stringname,"_*_*_*","_*_*_00")
to no avail.
Anyone have any guidance? Thank you!
Could someone help me understand why I'm failing at this?
I have a string with these contents:
_GDP_STUFF_158
_GDP_STUFF_20
_CPI_STUFF_120
_CPI_STUFF_1
I'd like to make a new string consisting only of two elements: "_GDP_STUFF_" and "_CPI_STUFF_". My strategy was to use @wreplace to replace the numbers with nonsense that I would then use @wdrop to get rid of, and then use @wunique to get me only unique elements.
If anyone has a more elegant way they've done something similar, please let me know. But outside of that, I am failing trying to get @wreplace to work.
Assuming the name of mu string is "stringname," I am trying things like:
string stringname=@wreplace(stringname,"_*_*_*","_*_*_00")
to no avail.
Anyone have any guidance? Thank you!