Regular expressions in JavaScript for CP5?

I'm having trouble implementing a regular expression from within the JavaScript window. First of all, does CP 5 support regular expressions?

On slide 1 I have a Text Entry Box, (called TheTeb) with a Submit button. TheTeb has variable associated with it called TypedText.
In the box, the user may type anything.
On slide 2 there is a caption.
The caption must show the text that the user typed  into TheTeb but filtered so that only the letters, numbers, and spaces can be shown.
For example,
if the user types:           123 & abc /DEF
the caption will show: 123 abc DEF
This requirement is represents the behavior of an application that I am simulating, so I don't want to change the interaction in any way.
My strategy is to use 2 different variables, one for the text entry box (TypedText), the other for the caption (FilteredText). I can add JavaScript to the On Enter event of slide 2. The script will Get the TypedText, pass the TypedText to FilteredText, and run a regular expression somewhere so the filtered text displays on slide 2.
Here's the script so far:
var objCP = document.Captivate;    
var ScriptTypedText = objCP.cpEIGetValue('TypedText');
function ReturnValue(){    
  objCP.cpEISetValue('FilteredText', ScriptTypedText);
ReturnValue();
The script works as is. The user types text on slide 1 (as TypedText), presses Enter and the text shows up on slide 2 (as $$FilteredText$$). Obviously, the trouble is, I don't know where to add my regular expression into the JavaScript so the text actually gets filtered. Do I make a new function?
By the way, a sort of pseudocode syntax for the expression would be:
FilteredText = TypedText.replace(/ /g,"");

Similar Messages

  • Regular expressing in javascript

    Hi All,
    Does anybody know if there's a way to find out how many words
    appear in a string using regular expression in javascript? For
    example, I have the following code that pops a "Not OK" alert
    whenever str contains "it it it information technology", and I need
    to find out how many times the word "it" exists in the string using
    regular expression.
    <html>
    <body>
    <script type="text/javascript">
    var str = "it it it information technology";
    var reg = /^(\bin\b|\bit\b|\bof\b)(?!
    (\bin\b|\bit\b|\bof\b))/;
    reg = new RegExp(reg);
    var result = str.match(reg);
    document.write(result);
    if (result) {
    alert("OK");
    } else {
    alert("Not OK");
    </script>
    </body>
    </html>
    Thanks very much in advance!

    Refer
    this
    tutorial.

  • Regular expression not working for adobe forms

    Hi,
    Iam using qtp for adobe forms and for some reason if i put in regular expression for apid value it doesn't recognise the object..there is nothing wrong with the regular expression as it is evaluated using regular expression evaluator in qtp 11.0....any ideas
    I got all the addins and everything and when i used regular expression for the top window it works but for any other object it doesn't

    Please try the code and see the problem. The regular expression is fine.
    I can replace the string with these and got results like this:
    import java.util.regex.Pattern;
    public class HtmlFilter implements TextFilter {
        private static String strTagPattern = "<\\s?(.|\n)*?\\s?>";
        private static int patternMode = Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.CANON_EQ;
        private static Pattern tagPattern = Pattern.compile(strTagPattern, patternMode);
        public String filter(String t) {
              if(t==null || t.length()==0) return "";
            String ret = null;
            return tagPattern.matcher(t).replaceAll("");
         public static void main(String[] args) {
              System.out.println(new HtmlFilter().filter(null));
              System.out.println(new HtmlFilter().filter(""));
              System.out.println(new HtmlFilter().filter("<P>abc def</P>"));
              System.out.println(new HtmlFilter().filter("<P>&#25105;&#22269;&#30707;&#27833;&#20379;&#24212;&#23433;&#20840;&#31995;&#32479;&#24433;&#21709;</P>"));
    }The results are
    abc def
    ????????????

  • Regular expression in oracle for hypen

    Hi,
    I want to match a word "{color:#993300}83-ASG{color}" using regexp_like and i used '{color:#993300}^83-*{color}' pattern to match this word but this also matches words like "{color:#993300}8307-YUF{color}". could anyone please tell me what pattern should i use to match words like {color:#993300}83-ASG{color}.
    Also i need to know the similar pattern in oracle for the "{color:#993300}\b{}{color}" used in .net.
    Thanks in advance.
    Prasad

    Hi Prasad,
    Your regex could be as simple as '^83-'
    So, not much use for a regular expression:
    SQL> with test_data as (select '83-ASG' txt from dual union all
                       select '8307-YUF' from dual)
    -- end of test data
    select txt from test_data
    where txt like '83-%'
    TXT    
    83-ASG 
    1 row selected.Unless, you add some more value to it, perhaps like
    SQL> with test_data as (select '83-ASG' txt from dual union all
                       select '8307-YUF' from dual)
    -- end of test data
    select txt from test_data
    where regexp_like(txt, '^83-[[:upper:]]{3}$')
    TXT    
    83-ASG 
    1 row selected.Regards
    Peter

  • Regular Expression item validation for email address

    Hi,
    Does anyone know of a regular expression I can use to validate an email address field? I am using Apex 3.2.
    Your help would be much appreciated.
    Thanks,
    ca84

    ^((\s*[a-zA-Z0-9\._%-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4}\s*[,;:]){1,100}?)?(\s*[a-zA-Z0-9\._%-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4})*$

  • Data generation using regular expression in c# for sql server

    Hello Everybody,
    I am using VS 2013 professional, SQL Server 2012.
    I am writing database application in c#. I have a table which stores starttime and endtime of operator
    As starting step, I inserted random DateTime into the table.
    But i would like hide some Patterns inside the database like it should insert some records that operator2 is absent on every second tuesday in every month in 2014 between 3AM to 4AM.
    How do i tell my c# code to insert that Patterns into databse. From some posts I understtod that it may be done by using regular expressions. But i did not find clear example.
    Could someone please tell me how to do it?
    Thank you so much.

    I'm not sure what exactly you're referring to, but I think you may be able to accomplish some of what you want by using triggers, constraints, and column defaults. These are database objects that are defined by using DDL, so have a look at the DDL reference
    (and other information about these objects) in SQL Server Books Online and see if these will do what you want. T-SQL implements a "pattern-wildcard language" that is not the same as regular expressions.
    In addition you can write SQLCLR objects (e.g. triggers and functions) that can use the .NET regular expression library, which is an implementation of the well-known regular expression library. There are a number of examples of SQLCLR/regular expressions
    around, a simple web search should suffice.
    Hope this helps, Bob

  • ReplaceAll string by regular expression not work for this case.

    I will delete all tag and want "pure text" but the output is delete all.
    String content = "<aaa>pure text<fff>";
    content = content.replaceAll("<.*>","");Content has output is blank because reqular expression match from begin and end of string
    But when i change
    String content = "<aaa>pure text<fff";
    content = content.replaceAll("<.*>","");The output is ==> pure text<fff
    How make req match in sequential
    Please lead me to solution

    peterdog1234 wrote:
    Thank you very much.
    I know '?' is a Quantifiers.
    I do not understand using ?
    Please lead me againSee the paragraph "Laziness Instead of Greediness" from [http://www.regular-expressions.info/repeat.html].

  • Regular expression not working for String.split()?

    hi, i have a String variable called 'table'.
    It has a bunch of chunks of data seperated by whitespace, whether it
    be spaces or carraige returns. Anyways, i want to split this up using
    the String.split function. i want to split it around whitespace.
    here is my code:
    String codes[] = table.split("\s");
    However, i'm getting back all nulls in the codes variable. What am i doing wrong?
    thanks

    split("\\s")\ is special both in Java String literals and in regex, so you need two of them.
    You'll probably also have to take an extra step it you don't want regex to stop at newlines. I forget the details, so check the docs.

  • Regular Expression to check for some of the special characters

    Can someone please provide me a RegularExpression to check if a string contains any of the speical characters i.e. *!@#$%^&*()_+ []{}:;',./<>?~`*
    Thanks
    Edited by: whitesox12 on Apr 3, 2008 9:46 PM

    [*!@#$%\^&()_+\[\]{}:;',./?~`]In a Java string literal, a backslash should be written as two consecutive backslashes.

  • Regular Expressions for textfield syntax checking while typing?

    Hi all,
    my application has a textfield for entering customer numbers. The customer numbers have a certain syntax which I want to have checked while the user types.
    According to our company's style guide, the textfield's background color has to be
    - RED in case of an error,
    - WHITE in case of correct input,
    - YELLOW when the input is incomplete but the beginning is correct.
    To check the syntax with Regular Expressions is easy for the WHITE and RED cases. But I'm struggling with the YELLOW case.
    public static boolean checkTest(String s) {
         String regExp = "(\\d{6,8},\\d{1,3},\\d{1,3},\\d{1,2})";
         return Pattern.matches(regExp, s);
    }The above method returns true for the following examples:
    "12345678,1,2,3"
    "123456,11,22,33"
    "1234567,123,123,12"
    I now need another method which returns true if the user entered a valid beginning, for example:
    "123"
    "1234567,"
    "123456,123,1"
    Any ideas? I would be glad to get this done...

    @notivago
    In the meantime I also came up with a pattern to
    check the YELLOW case:
    String partly =
    "\\d{0,8},?|\\d{6,8},\\d{0,3},?|\\d{6,8},\\d{1,3},\\d{
    0,3},?|\\d{6,8},\\d{1,3},\\d{1,3},\\d{0,2}";Sounds good to me.
    It seems to work. But my actual goal is to do such
    color-coded syntax checking for other number types
    (other patterns) as well. And it should be easy to
    add or change number types.I cant figure how to do that for now.
    So it would be nice to have a generic way to generate
    the YELLOW-pattern from the other one. Is it
    possible? Probably, but I cannot come up with any idea now.
    Is there a better solution than my one
    ("String partly" above)? Something I can just append
    to the original pattern for example?There are others, but it is hard to say what would be better or worse.

  • Indexing on regular expression seach for dynamic pattern

    Hello All,
    Would it be possible to create any index for regular expression search (REGEXP_LIKE) for 'dynamic' pattern?
    If the pattern is static, then we can create FBI, but is there any way for dynamic patterns? Please advise.
    Regards,
    Hari

    Thanks Dom, I have never used Oracle Text. Would it be possible to provide some sample code for above requirement.
    Regards,
    Hari

  • Regular expression: check for the presence of special characters.

    I have the following requirement:
    I need to check for the presence of the following characters in a keyword: @, #, > if any of these characters are present, then they need to be stripped off, before going further. Please let me know the regular expression to check for these characters.

    I am trying to extend the same logic for the following characters:
    .,‘“?!@#%^&*()-~<>[]{}\+=`©® . here is the code fragment:
    Pattern kValidator = Pattern.compile("[\\.,\\‘\\“?!@#%^&*()-~<>[]{}\\+=\\`©®]");
    Matcher kMatcher = kValidator.matcher(keyWord);
    if (kMatcher.find(0)) {
    keyWord = keyWord.replaceAll("[.,\\‘\\“?!@#%^&*()-~<>[]{}\\+=\\`©®]", " ");
    }I get the following error. This error is from the weblogic command window. I dont understand these special characters.
    Error:
    28 Oct 2008 12:27:48 | INFO  | SearchController   | Exception while fetching search results in controller:Unclosed character class near index
    39
    [\.,\&#915;Çÿ\&#915;Ç£?!@#%^&*()-~<>[]{}\+=\`&#9516;&#8976;&#9516;«]
                                           ^
    java.util.regex.PatternSyntaxException: Unclosed character class near index 39
    [\.,\&#915;Çÿ\&#915;Ç£?!@#%^&*()-~<>[]{}\+=\`&#9516;&#8976;&#9516;«]
                                           ^
            at java.util.regex.Pattern.error(Pattern.java:1650)
            at java.util.regex.Pattern.clazz(Pattern.java:2199)
            at java.util.regex.Pattern.sequence(Pattern.java:1727)
            at java.util.regex.Pattern.expr(Pattern.java:1687)
            at java.util.regex.Pattern.compile(Pattern.java:1397)
            at java.util.regex.Pattern.<init>(Pattern.java:1124)
            at java.util.regex.Pattern.compile(Pattern.java:817)

  • Regular Expression for multiline response from a device

    Hi,
    I am trying to have a regular expression in java for a response (example response is )
    Freq Table Info:
    # freqs = 12
    # trackers = 1 (LF), 1 (HF)
    fmin = 300000 Hz
    fsplit = 7000000 Hz
    fmax = 150000000 Hz
    updates = 1
    Freq Table:
    Slot | Mode | Description
    -----|------|---------------------------------------------------------
    0 | FUND | 400000 ( 400000
    1 | FUND | 13560000 ( 13560000) Hz, tracking = True
    Need to match this response and extract 400000 and 1356000 , stuck at mot being able to match the response. I tried [\\w]+[\\W]+ as well as \\w , dont think they work well enough, also tried testing on http://www.iowacomputergurus.com/free-products/regular-expression-tester.aspx, dont think am on the money yet. Can somebody please give any pointers or suggestions.
    Thanks for your time.

    PaddyK54 wrote:
    Hi,
    I am trying to have a regular expression in java for a response (example response is )
    Freq Table Info:               
    # freqs    =  12                
    # trackers =   1 (LF),   1 (HF)                               
    fmin       =     300000 Hz                          
    fsplit     =    7000000 Hz                          
    fmax       =  150000000 Hz                          
    updates    =          1                       
    Freq Table:          
    Slot | Mode | Description                         
    -----|------|---------------------------------------------------------                                                                      
    0  | FUND |     400000 (    400000                                  
    1  | FUND |   13560000 (  13560000) Hz, tracking = True       Need to match this response and extract 400000 and 1356000 , Well, given that input, your matches both are:
    - made of two or more digits,
    - followed by one or more spaces,
    - followed by an opening parentheses.
    So the regex \d{2,}(?=\s+\()would uniquely identify 400000 and 1356000 (with the example input you posted, which I know little about!). For all I know, other input may have opening parenthesis on other location in your string, which will break the regex.
    For example, what if the following line occurs in your input:
    # trackers = 123456 (LF), 1 (HF)
    You see how that breaks my suggested regex?

  • Combine 2 or more regular expressions

    Hello
    I would like to ask, if it is possible to combine more search and replace regular expressions in dreamweaver (direct input or combining .drw files)
    for example, something easy:
    search: Adobe
    replace: $1&reg;
    and in same step also:
    search: euro; ([0-9])([0-9])([0-9])([0-9]),([0-9])([0-9])
    replace: euro; $1.$2$3$4,$5$6
    I would like to speed up my work and instead of 3 searc&replaces use only one.
    Thanks for your help

    st3n wrote:
    I would like to ask, if it is possible to combine more search and replace regular expressions in dreamweaver (direct input or combining .drw files)
    No. Although it's possible to combine the regular expressions to search for the different values, there's only one replacement value. Using your example would not only add &reg; after Adobe, but also in front of euro;. Under the hood, Dreamweaver is simply using the JavaScript replace() method.
    By the way, your second regex could be simplified like this:
    search: (euro; \d)(\d{3},\d{2})
    replace: $1.$2

  • Sed Request Regular Expression Format

    A quick question....
    There are lots of different syntaxes for regular expressions and lots for SED. With the sed_request and sed_response filter I have tried different syntaxes for marking word boundaries, but don't know which to use. The \b syntax is supported but doesn't seem to do anything and the \< and \> syntax throughs up errors when I start up the web server. I tried the more complex (?<!\w)(?=\w) and (?<=\w)(?!\w) but the \w isn't supported. I am wondering if I just can't do this.... I am trying to stop SQL injection attacks using a syntax such as
    s/\bselect\b.{1,100}?\bfrom\b.{1,100}?\bwhere\b//g
    Are word boundaries not supported?

    Actually, the entries should be \\< and \\>, which looks double escaped to me but the entries are correct then
    Input fn="insert-filter"
    method="(GET|HEAD|POST)"
    filter="sed-request"
    sed="s/</\\</g"
    sed="s/%3c/\\</g"
    sed="s/%3C/\\</g"
    sed="s/>/\\>/g"
    sed="s/%3e/\\>/g"
    sed="s/%3E/\\>/g"
    sed="s/\x3C ?iframe//g"
    sed="s/\\<src\\>[^a-zA-Z_0-9]*?\\<javascript://g"
    sed="s/\\<src\\>[^a-zA-Z_0-9]*?\\<vbscript://g"
    sed="s/\\<href\\>[^a-zA-Z_0-9]*?\\<javascript://g"
    sed="s/\\<alert\\>[^a-zA-Z_0-9]*?\x28//g"
    sed="s/\\<src\\>[^a-zA-Z_0-9]*?\\<http://g"
    sed="s/\\<type\\>[^a-zA-Z_0-9]*?\\<text\\>[^a-zA-Z_0-9]*?\\<vbscript\\>//g"
    sed="s/\\<href\\>[^a-zA-Z_0-9]*?\\<vbscript://g"
    sed="s/\\<url\\>[^a-zA-Z_0-9]*?\\<javascript://g"
    sed="s/\x3C ?script\\>//g"
    sed="s/\\<type\\>[^a-zA-Z_0-9]*?\\<text\\>[^a-zA-Z_0-9]*?\\<javascript\\>//g"
    sed="s/\\<url\\>[^a-zA-Z_0-9]*?\\<vbscript://g"
    sed="s/(asfunction|javascript|vbscript|data|mocha|livescript)://g"
    sed="s/(?i:<object[ /+\t].*?((type)|(codetype)|(classid)|(code)|(data))[ /+\t]*=)//g"
    sed="s/(?i:[ /+\t\"\'`]datasrc[ +\t]*?=.)//g"
    sed="s/(?i:<link[ /+\t].*?href[ /+\t]*=)//g"
    sed="s/(?i:<meta[ /+\t].*?http-equiv[ /+\t]*=)//g"
    sed="s/(?i:<embed[ /+\t].*?SRC.*?=)//g"
    sed="s/(?i:[ /+\t\"\'`]on\x63\x63\x63+?[ +\t]*?=.)//g"
    sed="s/(?i:<?frame.*?[ /+\t]*?src[ /+\t]*=)//g"
    sed="s/(?i:<isindex[ /+\t>])//g"
    sed="s/(?i:<form.*?>)//g"
    sed="s/(?i:<script.*?[ /+\t]*?src[ /+\t]*=)//g"
    sed="s/(?i:<script.*?>)//g"
    sed="s/\\<select\\>.{0,40}buser\\>//g"
    sed="s/\\<select\\>.{0,40}\\<substring\\>//g"
    sed="s/\\<select\\>.{0,40}\\<ascii\\>//g"
    sed="s/\\<user_tables\\>//g"
    sed="s/\\<user_tab_columns\\>//g"
    sed="s/\\<all_objects\\>//g"
    sed="s/\\<drop\\>//g"
    sed="s/\\<substr\\>//g"
    sed="s/\\<sysdba\\>//g"
    sed="s/\\<user_password\\>//g"
    sed="s/\\<user_users\\>//g"
    sed="s/\\<user_constraints\\>//g"
    sed="s/\\<column_name\\>//g"
    sed="s/\\<substring\\>//g"
    sed="s/\\<object_type\\>//g"
    sed="s/\\<object_id\\>//g"
    sed="s/\\<user_ind_columns\\>//g"
    sed="s/\\<column_id\\>//g"
    sed="s/\\<table_name\\>//g"
    sed="s/\\<object_name\\>//g"
    sed="s/\\<rownum\\>//g"
    sed="s/\\<user_group\\>//g"
    sed="s/\\<utl_http\\>//g"
    sed="s/\\<select\\>.*?\\<to_number\\>//g"
    sed="s/\\<group\\>.*\\<byb.{1,100}?\\<having\\>//g"
    sed="s/\\<select\\>.*?\\<data_type\\>//g"
    sed="s/\\<isnull\\>[^a-zA-Z_0-9]*?\x28//g"
    sed="s/\\<union\\>.{1,100}?\\<select\\>//g"
    sed="s/\\<insert\\>[^a-zA-Z_0-9]*?\\<into\\>//g"
    sed="s/\\<select\\>.{1,100}?\\<count\\>.{1,100}?\\<from\\>//g"
    sed="s/\x3B[^a-zA-Z_0-9]*?\\<drop\\>//g"
    sed="s/\\<select\\>.*?\\<to_char\\>//g"
    sed="s/\\<dbms_java\\>//g"
    sed="s/\\<nvarchar\\>//g"
    sed="s/\\<utl_file\\>//g"
    sed="s/\\<inner\\>[^a-zA-Z_0-9]*?\\<join\\>//g"
    sed="s/\\<select\\>.{1,100}?\\<from\\>.{1,100}?\\<where\\>//g"
    sed="s/\\<intob[^a-zA-Z_0-9]*?\\<dumpfile\\>//g"
    sed="s/\\<delete\\>[^a-zA-Z_0-9]*?\\<from\\>//g"
    sed="s/\x3B[^a-zA-Z_0-9]*?\\<shutdown\\>//g"
    sed="s/\\<dba_users\\>//g"
    sed="s/\\<select\\>.{1,100}?\\<top\\>.{1,100}?\\<from\\>//g"

Maybe you are looking for

  • Xpath field details not getting displayed

    Hi all, I am working on a idoc to file scenario, where I want to refer the receiver to be determined based upon certain condition or values that get populated for a particular field (using receiver determination). But the problem is that when I click

  • Error in transfer structure while activating the business content

    Hi all         we got the following error while activating the transfer rules( business content) : 1)error when determining a number from object BI_TSDTEL and number 01 2) object name can only contain characters from syntactical character set. 3) dat

  • Will a Built-in Modem pulled from a Dual 867mhz work in my DP 500 Mhz  Mac

    Will a Built-in Modem pulled from a Dual 867mhz work in my DP 500 Mhz (Gigabyte Etherent) Mac? The info on the modem is: UO1MO85.00 The connectors are compatible, but I wasn't sure if the modem itself was. I'm looking to start faxing with my computer

  • Loading external (PDF)file into BLOB colum in the table.  Need urgent help.

    Hi All, I've currently been working on loading many external binary files (PDF) into BLOB column. After some digging, I learn that the SQL*LOADER can be used to load data from external files into table. I also got help from another forummate mentioni

  • Importing songs from CDs - not showing up in my Library

    I am aving trouble importing songs from CDs.  I completed the process as instructed - using the "import this CD" button (I have done this many times successfully). The import process ran OK.  When the Import process completed, I looked in my music Li