Need a regular expression to keep domain [closed] - regex

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have some URLs:
google.com
stack.bing.com
yahoo.com/text/4378
yahoo.com/65456/4378/76576
How to remove URL with more than 2 / characters? After removing, it only has:
google.com
stack.bing.com
How to do it with regular expressions?
In this link http://textmechanic.com/Remove-Lines-Containing.html, it has Enable regular expression search function. So, i want to use regular expression for it.

You can use this regex for matching URLs with less than 2 slashes excluding cases of http://example):
^(?!.*?\/[^\/\n]+\/).+$
RegEx Demo
Or you can inverse the regex for removal:
^(?=.*?\/[^\/\n]+\/).+$

Related

Search for pattern containing decimal using regular expressions in notepad++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have the following data in my notepad++ file:
aa(40)
aa(50)
aa(4)
aa(8)
aa(40)
How do I search for it using regular expressions in notepad++?
Note : aa is always constant
In Notepad++:
Go to Search >> Find
Select Regular Expressions
Enter following regex: ^aa\(\d+\)
Find All in All Opened Documents

regex for partial urls [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
does anyone know how to write the regex for this list of urls for workbox
/
/tracker/patientlist
/tracker/visitlist
/tracker/triage
i am new to regex
Assuming you want to match the root url /, or /tracker/*, try this:
/(tracker/\w+)?
Here is one way.(Not sure what other URI variations you may have, but this should do it). If the first part is always /tracker, then use Bohemian's answer.
(\/[a-zA-Z]+)

regular expression usage with [word1][wor2] [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a pattern like [word1][wor2]. I want to replace to {#link word2|word1}, word1, word2 could be anything.
I am very bad on using regular expression. Could anyone help me use regular expression match the pattern and replace to new pattern.
Thanks in advance.
Try the following find and replace, in regex mode:
Find: \[([^\]]+)\]\[([^\]]+)\]
Replace: {#link $2|$1}
Demo
The uses the approach of capturing the two adjacent word in square brackets, and then replacing with the text you want.

Angular ng-pattern regex code for US Zipcodes and Canadian Postal codes [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I could anybody help me out?
I am looking for some regexp to use to validate US Zip codes and Canadian Postal codes in AngularJS
This should work for you:
^(\d{5}(-\d{4})?|[A-Z]\d[A-Z] *\d[A-Z]\d)$
http://regex101.com/r/nO4zF5
Remove the ^ and $ anchors if you don't want to match the start and end of the string.
When using in Javascript remember that you need to use the / delimiter:
if (/^(\d{5}(-\d{4})?|[A-Z]\d[A-Z] *\d[A-Z]\d)$/.test(str)) {
// it's a match!
}
And directly, as an Angular ng-pattern:
ng-pattern="/^(\d{5}(-\d{4})?|[A-Z]\d[A-Z] *\d[A-Z]\d)$/"

Regex to search for everything before a string, and after [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I would like to search for everything before the string http://thepaperwall.com/wallpapers/ but not including that string.
I would also like to search for everything after .jpg but not including .jpg.
So my final string should look like this:
http://thepaperwall.com/wallpapers/cityscape/small/small_642331afcd78d0840485bb352d99b289b50e8467.jpg
How can I do this?
You can use look-behind and look-ahead to get a string position between 2 other strings:
(?<=http://thepaperwall.com/wallpapers/).*(?=\.jpg)
You need a non-capturing group:
(.*)(?:http:\/\/thepaperwall\.com\/wallpapers\/.*\.jpg)(.*)
Live demo