javascript - How would I get a certain part of a string? -
here's example string:
survey_questions_attributes_1317784471568_answers_attributes
i want 1317784471568
out of string.
but part text. example, may need string called new_questions
same spot in string.
the constant here survey_questions_attributes_
precede chunk want , _answers_attributes
follow it.
id = str.match(/_questions_attributes_(.+)_answers_attributes/)[1];
Comments
Post a Comment