Netbeans regular expression search and replace - regex

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

Related

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"]

Regex to modify an html tag

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>

Regular Expression for recognizing files with following patterns az.4.0.0.119.tgz

I am trying to find a regular expression that will recognize files with the pattern as az.4.0.0.119.tgz. I have tried the regular expression below:
([a-z]+)[.][0-9]{0,3}[.][0-9]{0,3}[.][0-9]{0,3}[.]tgz
But, no luck. Can anyone please point me in the right direction.
Regards,
Shreyas
Better to use a simple regex like this:
^([a-z]+)\.(?:[0-9]+\.)+tgz$
You just forgot one number part:
([a-z]+)[.][0-9]{0,3}[.][0-9]{0,3}[.][0-9]{0,3}[.][0-9]{0,3}[.]tgz
or
([a-z]+)[.]([0-9]{0,3}[.]){4}tgz
Depending on where and how you use the regex, you might want to surround it in ^...$.
Your pattern has 4 chiffers group, your regexp only 3.

VS2010 Find and Replace

I need help using regular expressions using Find and Replace in VS2010. I want to
Find request("somevar") and replace it with html_encode(request("somevar"))
somevar will be a different for each request("")
Replace request({:q}) with html_encode(request(\1)).

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