Regex to modify an html tag - regex

I am trying to replace
<legend>my legend</legend>
with
<legend><span>my legend</span></legend>
Intellij/Webstorm,supports regexp match and replace.
I tried along the examples here, but didn't work.
Any help on a regexp to find and replace as described above is appreciated.
I use mac, so gnu command line tools also an option (sed,..)
Thanks.

Use replace with the following regular expression:
<legend>([^<]*)</legend>
and replacement
<legend><span>$1</span></legend>

Related

Netbeans regular expression search and replace

I would like to find and replace in project on netbeans by using regular expression.
Find
$_SESSION['anything']['anything']
Replace with
$this->Session->read('anything.anything');
Please help.
You could accomplish this in the following way ...
Find \$_SESSION\['(.*?)'\]\['(.*?)'\]
Replace with \$this->Session->read('$1.$2');
see regex demo / explanation

Notepad++ Wildcard Find/Replace

I'm using Notepad++ and need to update a file where there are various differences in earlier sections of the string of text and think Wildcards may help here. From the research I've done thus far, it isn't clear what syntax would be used for this.
Here's an example of the original string:
"EEID","SUPLIFE","Voluntary Life Insurance","500000.00","500000.00",0,276,10.62.0,0,0,"20151112","","A","","","","",""
I'd like to find a way to add wildcards in the places noted below as WILDCARD:
"EEID","SUPLIFE","Voluntary Life Insurance","WILDCARD","WILDCARD",WILDCARD,WILDCARD,WILDCARD,WILDCARD,WILDCARD,WILDCARD,"20151112","","A","","","","",""
The final output would then look like the following after the find/replace with wildcards to add VLIFE:
"EEID","SUPLIFE","Voluntary Life Insurance","500000.00","500000.00",0,276,10.62.0,0,0,"20151112","","A","VLIFE","","","",""
Thanks,
Brandon
Tested in Notepad++ and appears to work:
("EEID","SUPLIFE","Voluntary Life Insurance",([^,]+,){8}"","A",)("")(.*)
and replace pattern:
\1"VLIFE"\4
Regex101 example

Find and replace using regular expressions (regex) in visual studio?

I am converting from VB.net to C#.Net.
I need to replace Session("something") or Session("Others") to Session["something"] or Session["Others"] in the whole project. What regex i need to use in the find box and what's in the replace box. Any help would be appreciated.
Make sure you check on the option use the regular expression.
Find what: Session\("{.*?}"\)
Replace with: Session["\1"]
Note: using lazy operator ? here is try to stop when finding the first match. Thus, it should be able to handle cases like:
Session("Types") = new SelectList(xxx, "Code", "Description");
((((Session("something)))))))))"))))
P.S.: In VS2013, you should use the following instead:
Find what: Session\("(.*?)"\)
Replace with: Session["$1"]

Notepad++ replace with reg expression?

I have a big list with links and other date in it. I want to filter out all the data and have a list with just the links.
Example of the current list:
32,2012-01-04 06:44:44,http://link.com/link
33,2012-01-04 06:44:45,http://link.com/link,{Text|textext|text},http://link.com/link|http://link.com/link|http://link.com/link
Notepad++ offers find replace functionality using RegEx. You can access this feature by using Ctrl+H.
If you're actually asking for a regular expression to do this, you can use something like this to match URLs:
\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))
which I found here.
Additionally you can test out changes to your regex easily at http://gskinner.com/RegExr/
Using the input you provided, here's a pattern you can use on http://www.regexr.com/
You'll need to make sure the global (/g) flag is on
Expression:
.*?(http.*?)[,|\n]
Input:
32,2012-01-04 06:44:44,http://link.com/link1
33,2012-01-04 06:44:45,http://link.com/link2,{Text|textext|text},http://link.com/link3|http://link.com/link4|http://link.com/link5
Substitution:
$1\n
Output:
http://link.com/link1
http://link.com/link2
http://link.com/link3
http://link.com/link4
http://link.com/link5

Notepad++ I'm looking for a regexp to select all occurances of 'href="' that do not match 'href="javascript'

This is about the code editor Notepad++.
I'm looking for a regular expression that will solve the following problem:
I have a set of html files. I need to find all links in them that are not links to javascript functions. If I search for the string 'href="' I get 342 results and if I search for 'href="javascript' I get 301 results. I'd like to get at the 41 elements that are only in the first set. That is all links that are not to javascript function calls.
I'd be grateful if anyone more familiar with regular expressions than I currently am could help me out on this one.
This will match urls that don't start with "j", which probably will work for you.
href="[^j]
I don't know what type of RegExp engine is used in Notepad++ but the extended regular expression would look like:
href="(?:(?!javascript).)
PowerGrep w/ RegexBuddy - I use notepad++ and PowerGrep