i am trying to parse out a string and in some cases there is an extra " - [some number]" at the end. for example,
instead of showing
Technologist
it shows
Technologist - 23423
i dont want to just check or split on "-" because there are other names that do have a "-" in them
can anyone think of a clean way of removing this extra noise so:
Technologist - 23423 resolves to Technologist
Try this regular expression:
This will work on the following strings (all is evaluating to
Text
):This looks like a case regular expressions, such as @" - \d+$" in this case. Sample code:
Note that this currently doesn't spot negative numbers. If you wanted it to, you could use