How do I remove the last part of every line in notepad++?

8

I know this can be done in notepad++, but I'm not finding the right replace syntax.

I want to remove the last part of this sentence, starting from ?:

http://sportnaslava.info/wiki/index.php?title=User:CisBlakeman861

so that it becomes:

http://sportnaslava.info/wiki/index.php

king

Posted 2012-02-18T11:48:59.833

Reputation: 81

Answers

18

The regexp is \?.*$

\? mean question mark itself
.* mean everything else
$ means the end of line.

So we search something starting with question mark and lasts to the end of line. Don't forget to set "search mode" to "regular expression"

enter image description here

Putnik

Posted 2012-02-18T11:48:59.833

Reputation: 692

thanks a lot man that helped and what about lines with out ? example http://lunar.earth.northwestern.edu/mediawiki/index.php/Limitless_It_the_film_high_quality replace to http://lunar.earth.northwestern.edu/mediawiki/index.php/

– king – 2012-02-18T12:49:21.230

4

http://lunar.earth.northwestern.edu/mediawiki/index.php/Limitless_It_the_film_high_quality
http://sportnaslava.info/wiki/index.php?title=User:CisBlakeman861

Using those examples, it would be better to use something like:

index\.php.*$

Then replace with:

index.php

That should find everything after (and including) index.php, and replace it with just index.php.

http://lunar.earth.northwestern.edu/mediawiki/index.php
http://sportnaslava.info/wiki/index.php

Josh

Posted 2012-02-18T11:48:59.833

Reputation: 364

thank you so much, putnik, alex and josh you guys solved it – king – 2012-02-18T14:49:27.603