Reputation: 65
I want to replace
$this->input->post("product_name");
with
$post_data["product_name"];
I want to use notepad++ regex, but I couldn't find proper solution
In find --> $this->input->post("[\*w\]");
In replace --> $post_data["$1"];
but its not working
Upvotes: 1
Views: 615
Reputation: 2326
$this->input->post("product_name");
by
$post_data["product_name"];
do replace, with regex activated
this->input->post\("(.*)"\);
by
post_data\["\1"\];
The \x
with x a number, corresponds to the x-th match catched with the parenthesis. Here we catch any character inside this->input->post(XXXX);
Don't forget to escape special character with \
.
Your special characters were []()
Upvotes: 0
Reputation: 37367
Use this pattern to match desired text \$this->input->post\(("[^"]+")\);
And replace it with pattern \$post_data\[\1\]
Explanation:
\$this->input->post
- matach $this->input->post
literally
\(("[^"]+")\);
- match (
literally, then match double quates and everything between them with "[^"]+"
and store inside first capturing group, then match );
literally
Upvotes: 0
Reputation: 626893
The $this->input->post("[\*w\]");
pattern does not work because:
$
is a special char matching the end of a line, you need to use \$
to match it as a literal char[\*w'\]
is a malformed pattern as there is no matching unescaped ]
for the [
that opens a character class. Also, w
just matches w
, not any letter, digit or underscore, \w
does that.You may use
Find What: \$this->input->post\("(\w*)"\);
Replace With: $post_data["$1"];
If there can be any char inside double quotes use .*?
instead of \w*
:
Find What: \$this->input->post\("(.*?)"\);
NPP test:
Upvotes: 1