Using Regular expression in jscript - InfoPath Dev
in

InfoPath Dev

Using Regular expression in jscript

Last post 03-29-2005 03:41 PM by Greg Collins. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-28-2005 10:40 PM

    • amish
    • Not Ranked
    • Joined on 12-24-2004
    • India
    • Posts 19

    Using Regular expression in jscript

    HiGuys,
    Back again with a problem(most probably a silly one).

    I have written a function that will find a specifc pattern (in my case a date string in format mm-dd-yyyy.This date can be at any position in the input string) and replace it with something other string .
    The following is the function for that :
    ***************************************************************
    function ReplaceDate(strInput)
    {
    var strResult;
    var objRegex = new RegExp("\d{1,2}-\d{1,2}-\d{4}"); //mm-dd-yyyy
    strResult = strInput.replace(objRegex, "HERO");
    return(strResult);
    }
    ***************************************************************
    The regular expression used to search the date string looks fine.

    The problem is that when i call this function , the function is NOT able to FIND& REPLACE date even though there is a date present in mm-dd-yyyy format in the input string.

    Can you please tell me where am i going wrong?



    Amish
  • 03-29-2005 03:41 PM In reply to

    Re: Using Regular expression in jscript

    Where is this function being called from? And what is the error you are receiving?

    Greg Collins [InfoPath MVP]
    InfoPathDev
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.