Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++ wildcard

Tags:

notepad++

how to find and replace all characters after the main domain (including the "/" character) using a wild card?

For example, i have the following 4 rows:

intersport-schaeftlmaier.de/
weymouthhondapowersports.com/Default.asp
rtbstream.com/click?data=RG1kUFJQQUYw
top-casino-sites.com/

In excel I would simply use the following: Find this /* Replace with this

The results will look like this:

intersport-schaeftlmaier.de
weymouthhondapowersports.com
rtbstream.com
top-casino-sites.com

So, how to do that with notepad++ ?

Thanks, Ziv

like image 814
Ziv Avatar asked Jun 10 '16 07:06

Ziv


People also ask

How do you do a wildcard in notepad?

Open the search/replace dialog ( CTRL + F then the replace tab) Tick "Regular Expression" down the bottom. Use . * as the wildcard.

How do you type a wildcard?

To match special characters like question mark (?), number sign (#), and asterisk (*), put them in square brackets.

What is a * symbol in a wildcard characters?

In software, a wildcard character is a kind of placeholder represented by a single character, such as an asterisk ( * ), which can be interpreted as a number of literal characters or an empty string. It is often used in file searches so the full name need not be typed.

What does the wildcard operator * do?

An asterisk (*) may be used to specify any number of characters. It is typically used at the end of a root word, when it is referred to as "truncation." This is great when you want to search for variable endings of a root word.


2 Answers

In the Find and Replace dialog:

  • under Search Mode select Regular Expression
  • set Find What to /.*$
  • leave Replace With empty

This is replace any slash and all the text after it until the end of line with nothing. It uses a regular expression so it looks convoluted but it is well worth learning as regular expressions are insanely useful for lots of things.

Basically:

  • / isn't a special character so it just matches a /
  • . is a wildcard that matches a single character. To match a literal . use \.
  • * is a wildcard that matches zero of more of the preceding character. So a* would match zero or more a and .* would match zero of more of any character.
  • $ matches the end of a line. To match a literal $ use \$

A few other special characters:

  • \ is the escape character - use it to turn special characters into normal characters. Yo match a literal \ use \\
  • + is a wildcard that matches one of more of the preceding character. So a+ would match one or more a and .+ would match one of more of any character.
  • ^ matches the start of a line. To match a literal ^ use \^
  • ( and ) make a match group. To match literal ( or ) use \( and \)

And there are more special characters including [, ], { and } along with others that I won't mention.

like image 63
Jerry Jeremiah Avatar answered Sep 19 '22 08:09

Jerry Jeremiah


Use Regular Expression in Replace and then use this:

/.*

Untick the . matches newline and ofc replace it with nothing ;)

like image 27
Mono Avatar answered Sep 19 '22 08:09

Mono