Retrieving part of a string using jQuery / JavaScript

Posted by ILMV on Stack Overflow See other posts from Stack Overflow or by ILMV
Published on 2010-03-25T15:46:16Z Indexed on 2010/03/25 15:53 UTC
Read the original article Hit count: 393

Filed under:
|
|

I know how I would achieve this using PHP, but with jQuery / JavaScript I'm not sure how to, here's the string I'm dealing with (It's the name attribute from a input element):

Field[0][some_random_text]

I want to retrieve the value some_random_text and slap it in a variable, I guess I would usually use regex to accomplish this task but not sure how this is done in JavaScript. Here are some characteristics of this name attribute.

  • It will always be in this format string[string][string]
  • Each of the strings can be any length

How would I get the some_random_text string?

I'd like to stick to the standard set of functions if possible.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript