hi, need help in removing two words in a sentence
string := 223344-OPERATIONS 21X700 (Line A)
need to remove OPERATIONS and (Line A)
final result should be 223344- 21X700
The sentence will always start with 6 digits and have a hyphen, but the word OPERATIONS could be short form OPER and the word in the brackets could also be short as well - (LNA) or (LA).
So maybe a rule to remove the word after the hyphen and then the end of the sentence with the brackets?
thanks for reading and helping
Help with RegExReplace Topic is solved
-
- Posts: 54
- Joined: 21 Oct 2017, 13:38
- AlphaBravo
- Posts: 586
- Joined: 29 Sep 2013, 22:59
Re: Help with RegExReplace
Code: Select all
string := "223344-OPERATIONS 21X700 (Line A)"
MsgBox % RegExReplace(string , "^\d{6}-\K\w+|\([^()]*?\)$")
Re: Help with RegExReplace Topic is solved
This should basically do what you are describing. Start with six digits, ignore the next word, then get a space and anything up to the (, then ignore the rest of the line.Bad husband wrote: ↑18 Nov 2022, 22:40final result should be 223344- 21X700
The sentence will always start with 6 digits and have a hyphen, but the word OPERATIONS could be short form OPER and the word in the brackets could also be short as well - (LNA) or (LA).
So maybe a rule to remove the word after the hyphen and then the end of the sentence with the brackets?
Code: Select all
MsgBox % RegExReplace("223344-OPERATIONS 21X700 (Line A)", "^(\d{6}-)\w+(\s.+)\(.+", "$1$2")
-
- Posts: 54
- Joined: 21 Oct 2017, 13:38
Re: Help with RegExReplace
both work for my needs
Thanks for your help
Thanks for your help
Who is online
Users browsing this forum: Bing [Bot], chubbychub, Chunjee and 73 guests