Search code examples
regexnotepad++

How to remove || expressions from end of string using regex on notepad++?


I have strings which look like this

न च <तुल्य-गुणः>K1  दूष्यः  न दोषः प्रकृतिः भवेत्|| 11 ||
उक्ताः  महाचतुष्पादे येषु आयत्तं <भिषक्-जितम्>T3|| 24 ||

My goal is to remove the digits and the || symbol they are contained within at the end of the string. I tried using this expression \|\|[0-9.]+\|\| but it only worked for a few of the instances. What expression can I try? Please note I am doing this on Notepad++.


Solution

  • Since you are only concerned about the end of the string, you'll want to use $

    so try: (\s*\|\| [\d]* \|\|)$ and replace with empty textbox.

    enter image description here

    after click Replace All

    enter image description here