remove string after a limiter
-
Hello everyone, so i wanted to clear a list which has a limiter " || " already tried experimenting with some regex
here’s an example of the content in the files
client@mail.com:orderID || Payment Date
So what i’m trying to do is remove " || Payment Date " with regex, i can’t just replace the string because everyline would have a different date. all i can do is use the " || " as reference because it constant
thank you! -
find:
(?-s)\|\|.+
repl: nothing -
Works like charm, tysm
-
Please try this regex,
Search: (?-s)^.+?\K\Q ||\E.+$ Replace: [leave empty]Put the caret at the very beginning of the file, select just the
Regular Expressions modeand click onReplace All.Take care and have fun!
Edit: Alan beat me!
-
Hi, @clyde-parker, @alan-kilborn, @astrosofista and All,
Alanbeat me too. Moreover, with exactly the same regex :-)
@clyde-parker, this search regex is quite obvious !
Notes :
-
First the
(?-s)is an in-line modifier which forces the regex engine to see any meta-character.as matching a single standard char ( so not theEOLcharacters ) -
Then the part
\|\|represents two literal pipe characters. They must be escaped as|is the meta-character for defining alternatives -
Finally, the part
.+matches for any non-empty range of standard characters …till the end of current line, so any existingPayment Date -
The overall match
||Payment Date, is simply deleted as the replacement zone is empty
To learn how to build regular expressions, I strongly advice you to carefully read this FAQ. It should not be difficult to master the basic concepts, in a week or so ;-))
Best Regards,
guy038
-
-
@guy038 said in remove string after a limiter:
Alan beat me too. Moreover, with exactly the same regex :-)
Haha, well does this show that some of us are learning?
See, it can happen, people!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login