Basically all over the document I have values like
2014-01-23 15:09:31.879958
I want to remove the last 6 digits and the . using find and replace. I've gotten
(\d{6})
To find the 6 digits but I also need it to find the . so I can replace it with nothing
Try: \.\d{6} - the \. escapes the dot.
In this case, you should be able to simply add a period to your find/replace.
As a test, I copied your example multiple times in a document. I then attempted to Find the following: \.(\d{6}) and replace with a blank
Give that a try and see if that works for you.
Cheers,
Edited to add the slash that I apparently didn't type. Silly.
Related
This is what I got:
.*([1-30000]#.*#).*
However, I would like to follow these rules without limiting to only 1 line.
For example, using: .*([1-30000]#.*#).* I could find:
5173#bunch of text here#
And what I would like to find:
5173#bunch of text here
of, bunch here, text
text here, bunch of
#
Hope I managed to be clear about my problem, thanks for the help.
Edit:
\b(?:[12]?\d{1,4}|30{4})#[^#]+#
Seems to be working, now the "challenge" is another, i want to save the number before the # (5173#) and replace what i got into another file where the same number is found.
You may use this regex:
(?<=\d#)[^#]+
Enable . matches newline and regex in your NP++ search box.
This matches text preceded by only a single digit followed by a pound and succeeded by a pound since NP++ doesn't support variable-length lookbehinds.
With the contribution of all, that is, joining what was answered by you. I got:
\b(?:[12]?\d{1,4}|30{4})#[^#]+#
I'm not sure if there's any mistake, I'm not familiar with all of this. :)
https://regex101.com/r/t7xBXk/1
Say, we have HTML-page, containing links:
a href="katalog/koshelki-i-klatchi/muzhskaya-sumka-planshet-polo-optom1"
a href="katalog/koshelki/kozhanaya-sumka-jeep-optom1"
I need to search using regex one time only (in one search query), and I want output to be:
koshelki-i-klatchi/muzhskaya-sumka-planshet-polo-optom1
koshelki/kozhanaya-sumka-jeep-optom1
What would regular expression for this task be like?
Do you want something like this:
http:\/\/[A-Za-z0-9\.]*(\/[A-Za-z0-9]*)?\/[A-Za-z0-9]+[0-9]{1}
Test it here: https://regex101.com/r/cnxvR0/1
It will match anything starting with http:// followed by any alphabet character, any digit or . (dot), optionally followed by another forward slash (/) and ends with 1 or more alphabet characters or digits and it has to end with a single digit.
I'm sure this will not help for all of your cases, but you have to be more specific, how many digits are there at the end, is it always only one ? Does the URL have to end with a digit or it's optional ? How many nested directories can there be (I made my regex for only one) ?
Let me know if the regex above will do what you need or post in the comment section answers to the questions above and I'll edit my answer accordingly.
OK SO AFTER YOU EDITED YOUR ORIGINAL QUESTION:
(?<=href=")(?:[\w-]+\/?)*
Try it here: https://regex101.com/r/q0tf5l/2
Let me know if this is what you wanted, you can iterate through all of the matches and print them out or whatever you need to do with them.
I need to go through a file and replace all instances where an issue is mentioned using the Github convention #xxx (where xxx is the issue number), with a link to the issue using the Markdown format.
So for example, this:
#143, #99
should be converted into this:
[#143](https://github.com/repo/issues/143), [#99](https://github.com/repo/issues/99)
I've gotten as far as to being able to select all the issues with three digits using:
#..[0-9]
but this leaves out the two or one digits issues (ie: #5 or #23)
Is there a way to generalize the above command to select all issues, no matter how many digits they have?
Once this is done, how can I make the replacement to add a link to each issue?
You should use this regex:
#[0-9]{1,3}
to match a issue # between 1 and 3 digits as [0-9]{1,3} will match a number that is 1 to 3 in length.
You can also use use word boundaries:
#[0-9]+\b
You need the regex #(\d+) and replace with [#$1](https://github.com/repo/issues/$1)
Try this regex for what you are trying to do
#[0-9]{1,3}
I'm trying to find a regex for removing everything after the last dot in a file. So far I've found ways to remove all text before the first dot, but I can't seem to find a way to select the end of the file. Could you help me on the way?
Thanks in advance
You can try something like:
\.[^.]*$
to match everything including and after the last dot. If you don't want to include the last dot, then you can use a positive lookbehind:
(?<=\.)[^.]*$
Try following regex for search and replace
s/\.[^.]*$/\./
On Bigquery, r'([^.]+).?$' works, if you want to remove the last dot.
I am quite new at Regex and would like to remove the following text:
1/10 2/10 3/10 4/10 5/10 6/10 7/10 8/10 9/10 10/10
I was thinking something like:
/1(.*)10(.*)2(.*)10(.*)3(.*)10(.*)10/s
but this doesnt seem to do the trick, it does remove the text, but it removes some other things too. Some images also contain numbers, so it starts to remove from the number in the image on.
So what i am looking for is to remove the exact text as above only
You have a couple of problems here.
1) You are matching multiple characters with .* when there's only one character there (either a slash or a space). You could simply use a . to match a single character.
2) You don't even need to do that. Why not use a literal, escaped slash \/ and space respectively?
If you want to remove that exact text, I suggest using string.Replace instead of using regular expressions... that is if you're using a language with a string replace function.
Thanks for the help! As i mentioned i am new at Regex, so please forgive my teminology.
Anyway i have matched the text with /1.10.2.10.3.10.4.10.5.10.6.10.7.10.8.10.9.10.10.10/ and replaced it with a blank field and that has done the trick!
Thanks for the hints and the support, it is really appreciated!