0

How can I replace text in NetBeans using regular expressions?

For instance,

I want to replace these texts below,

$item->article_id
$item->title
$item->content
...

with

$item['article_id']
$item['title']
$item['content']
...

I tried with this below in the input field of 'Containing Text:'

$item->(.*)

But no match found.

Any ideas?

2
  • Try with: $item->(.*?) does that do the trick for you? Commented Feb 24, 2015 at 9:31
  • nope. still the same. no match found... Commented Feb 24, 2015 at 9:36

3 Answers 3

2

If you write special characters, like $ sign in the Find what input, you must escape it with \ (backslash). But you don't need replace the $ sign with another $ sign.

In Find what:

item->(.*)

In Replace with:

item['$1'];

Then press replace all. That's all.

Sign up to request clarification or add additional context in comments.

Comments

2

You can try this to match the content.

item->([a-z]*...)

Comments

1

Use this

item->([a-z]*)

or

item->(.*)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.