I have this file with thousands of records (more thank 300.000) and I have to replace all the occurrences of a particular string but keeping some of it.
I'll give you an example, the string would be
\123
\34565
\923
..etc
so basically I would have to convert these strings in to
'|''|'123'
'|''|'34565'
'|''|'923'
does anyone have a quick solution for this?
Many thanks
Try this -
Regex - \\(\d+)
Replace with - '|''|'\1'
Demo here
Use this regex:
\\(\d+)
You should use g(global) modifier to match all. So your final regex would become:
/\\(\d+)/g
and replace it with:
'|''|'$1'
Demo:http://regex101.com/r/yO3xQ6
Related
I have a list of the following strings:
/fajwe/conv_1/routing/apwfe/afjwepfj
/fajwe/conv_2/routing/apwfe
/fajwe/conv_2/routing
/fajwe/conv_3/routing/apwfe/afjwepfj/awef
/fajwe/conv_4/routing/apwfe/afjwepfj/awef/0o09
I want a regex to only match string contains no more than 1 / after the word routing. Namely /fajwe/conv_2/routing/apwfe and /fajwe/conv_2/routing.
Currently I use the regex ^((?!rou\w+(\/\w+){2,}).)*$ but it matches nothing. How can I write a regex to exclude strings contains more than 2 / after the word routing?
I would love to learn how to achieve this using Negative Lookbehind. Many thanks!
Something like this?
^.*\/routing(\/[^\/]*){0,1}$
routing(\/[^\/]*)?$
there you go
https://regex101.com/r/KjE8ed/1/
Your regex matches what you are looking for with the multiline flag m as #revo pointed out.
^((?!rou\w+(\/\w+){2,}).)*$
You could also try it like this:
^\/fajwe\/conv_\d\/routing(?:\/[^\/]+)?$
Depending of your context of language you could \/ escape the forward slash
hey guys my regex skills suck and was looking for some help. I am using Notepad++ and am looking to easily replace everything between the following
example:
.dodo?ReplaceMe</dada>
Its in many lines i need to replace often so rather than hunting hightlighting and replacing i was hoping to score an easyier regex method that will save me time. The replace can include question mark if it makes it easier. Thanks in advance
You can match your pattern using \.dodo\?([^<]*)<\/dada>.
\.dodo\? matches .dodo? - you need to escape the . and ??
([^<]*) matches all characters aren't a <, ReplaceMe in this case, in a matching group
<\/dada> matches </dada> - you need to escape the /
View it in action here: https://regex101.com/r/bM2wE6/1
Use lookarounds:
(?<=\.dodo\?).*?(?=<\/dada>)
See it in action
I'm hoping some regexp guru to help me out with this:
I have strings such as [[AB]], [[ABC]] and [[BEC]], and I want to replace them with string {{param|AB}}, {{param|ABC}} and {{param|BEC}} respectively.
All source strings are inside [[]] and have 2 or 3 upper case letters. The idea is to transfer the letters inside brackets to the new format. It's fine if I need two different regexps for 2 and 3 letter long cases.
(if curious, this is for replacing large number of links with templates in a Mediawiki based page).
Thanks in advance!
You can replace the result of following regex :
/\[\[([A-Z]{2,3})\]\]/
with :
{{/param\|\1/}}
Not that some regex engines use $ for capture group so you may need to use {{/param\|$1/}}
If you want to exclude some words you can use a negative look ahead :
/^\[\[((?!AAA|BBB|CCC)[A-Z]{2,3})]]$/gm
But note that since that preceding regex use anchors if you are dealing with a multiline string you need to use m flag (multiline flag).
See demo https://regex101.com/r/cR8zG6/1
You can search using this regex:
\[\[(\w+)\]\]
and replace using:
{{param|$1}}
RegEx Demo
Not much of a expert in regular expression here. My IT colleague dump my a text file which containt all our mailing list. But I need to clean it before using it.
I need to find and delete a string of text which always start by "3EA" and finish by "////".
I try several ways, but no cigars.
Here's some example of the string I need to delete :
3AEAEACjkCjm////
3AEAEACjlCjn////
3AEAEACjnCjp////
Thanks
3AE[a-zA-Z]{9}/{4}
Try this.See demo.
https://regex101.com/r/vN3sH3/61
You could use the below regex,
3EA\S*?////
Add anchors if necessary.
^3EA\S*?////$
Assuming there are always 9 alphabetical characters in between 3AE and ////, in search and replace (in regex mode) replace this pattern with a blank pattern:
3AE[A-Za-z]{9}////
I am looking to extract "2" from the query parameter using Regex -
http://www.example.com?param=1|2|3|4|test¶m1=5|6
Regex used -
.*param=.*\|(\w+)\|.*
The output I get is "4".
I have even tried this to no avail -
.*param=.*\|(.*?)\|.*
Any help is much appreciated.
Thanks
You need to make the first .* non-greedy:
param=.*?\|(\w+)\|
or make it not match a pipe:
param=[^|]*\|(\w+)\|
Using you regex, simply add a ? after .* to capture as less characters as possible :
.*param=.*?\|(\w+)\|.*
\|(\w+)\|
Try this .See demo.
http://regex101.com/r/rQ5jJ3/1