Results 1 to 3 of 3

Thread: Finding a string in a string: regex question

  1. #1

    Default Finding a string in a string: regex question

    Hi,

    I know this is not a extjs specific question, but I need it solved in order to go with my extjs project.

    I have a long json string with the string "size: (x,y)," included where x and y are arbitrary numbers. I need a way to extract this string from the json string.
    I think I should use the js match function, but I don't know how to make the regexp for this?

    Thanks!

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Try:

    Code:
    var xy = jsonText.match(/size: \(\s?([0-9]+)\s?,\s?([0-9]+)\s?\)/);
    alert(xy[1] + ',' + xy[2]);

  3. #3

    Default

    Thanks! -that works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •