Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regexp question

Status
Not open for further replies.

jonnybongas

Programmer
Joined
Apr 1, 2007
Messages
1
Location
SE
I have a variable like the one below. It contains nested braces pair. I'd like to create a regexp that changes the variable value to the string "hello world". Can anyone help with me this?

$test = "hello
{{ text
{{innerbrace}}
some text
{{innerbrace2}}
some text
}} world";


//John
 
Hi

To do exactly what you asked for the following is enough :
Code:
$test=~s/\{.*\}//s;
$test=~s/\n//;
But I think this is not all and you would like to specify more requirements.

Feherke.
 
Hi Johnny,

Based off the requirements that you've stated thus far, the easiest and most direct solution would be:

Code:
$test =~ s/.*/hello world/s;

I presume that this is not what you're really wanting to do though. What are you trying to learn?

- Miller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top