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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract string from between brackets 1

Status
Not open for further replies.

rgatrell

Technical User
Sep 6, 2003
14
0
0
GB
Hi,

I need to extract a value from a dynamically changing string but only the bit between a set of brackets, e.g.

var exampleString1 = "some text (I need this bit)"
var exampleString2 = "some more text (value to store)"

Output:

exampleString1 = I need this bit
exampleString2 = value to store

Thanks in advance!
 
Hi

JavaScript:
extractor[teal]=[/teal][fuchsia]/\((.*)\)/[/fuchsia]
exampleString1[teal]=[/teal]extractor[teal].[/teal][COLOR=darkgoldenrod]exec[/color][teal]([/teal]exampleString1[teal])[[/teal][purple]1[/purple][teal]][/teal]
exampleString2[teal]=[/teal]extractor[teal].[/teal][COLOR=darkgoldenrod]exec[/color][teal]([/teal]exampleString2[teal])[[/teal][purple]1[/purple][teal]][/teal]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top