Results 1 to 13 of 13
  1. #1
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default Regex for the pattern

    Hello,

    I need a pattern for the following use cases: I am using Java

    1. var so = nokia.device.load('abc','abc');
    2. var so = nokia.device.load("abc","abc");
    3. var so = nokia.device.load("abc");
    4. var so = nokia.device.load('abc');
    // 5. var so = nokia.device.load('abc'); (Line is commentted)
    /*
    function init()
    {
    if (window.menu) {
    // set tab-navigation mode and hide softkeys
    widget.setNavigationEnabled(false);
    var so = nokia.device.load("abc");(Line is commentted)
    }
    */

    I need a regex pattern which will be give me only the function statments which are listed in bold and NOT italic format function statements as those statements are commented.

    Basically, the pattern should give me the statments which are not commented.
    Please help me, its urgent.

    Thanks,
    Mallikarjun.

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by mallikarjun_sg View Post
    I need a regex pattern which will be give me only the function statments which are listed in bold and NOT italic format function statements as those statements are commented.

    and what about function statements inside comments that starts with /*?

  3. #3
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default Need Regex for the pattern

    If the statement is commented, then those statements should be skipped during the pattern search...

    Regards,
    Mallikarjun

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

  6. #6
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    IgnoreList++;
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default

    Don't you think you should inform members here that your question is already answered on another forum? Or maybe it just doesn't bother you that someone may waste time trying to help you with a problem that no longer exists.

    db

  8. #8
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default

    I have got answered in other forum. Pattern is ^var *.*nokia[.]device.*[)] *;$

    Thank you...

  9. #9
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default ***Urgent Java regex Pattern

    Hello,
    Need a pattern for the problem. please check the last comment in the below link

    Java Programming - ***Need Regex for a pattern

    its urgent. Any assistance is highly appreciated.

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,457
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by mallikarjun_sg View Post
    Hello,
    Need a pattern for the problem. please check the last comment in the below link

    Java Programming - ***Need Regex for a pattern

    its urgent. Any assistance is highly appreciated.
    It isn't urgent to me nor is it urgent to anyone else here; I'd advise you to use a parser. You are reluctant to use parsers, possibly because you don't know how to use them but regexps are not really a solution here.

    kind regards,

    Jos

  11. #11
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default

    I am searching this String/pattern in JavaScript file (.js) and HTML file (.html) parsing the JS file is very vague. Parser treats every string is one Node, and so its bit complex to identify for a specific string/pattern. This is the reason for not using parser.
    So I switched back to Regex Pattern.

    I am doing reverse logic, as i mentioned in the above link (last comment in the link)

    Regards,
    Mallikarjun.

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,457
    Blog Entries
    7
    Rep Power
    20

    Default

    Why don't you use this ECMA Script grammar; ANTLR can be used to generate a parser from this grammar. Tweak the analizer part for variable initialization parts and see if your expression matches your goal. If so, process it and be done with it.

    kind regards,

    Jos

  13. #13
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default

    Hello,

    I have got a solution for JS and HTML files

    HTML pattern to identify all the comments :
    \\<![ \\r\\n\\t]*(--([^\\-]|[\\r\\n]|-[^\\-])*--[ \\r\\n\\t]*)\\>

    JS Pattern to identify all the comments (single, block..etc)
    (?:/\\*(?:[^*]|(?:\\*+[^*/]))*\\*+/)|(?://.*)

    So, here i will remove all the commented code and then, find the pattern (object.device.load...) in the uncommented code. Its easy to find it.

    Thanks for all your valuable inputs.

Similar Threads

  1. Specific syntax? java.util.regex.Pattern$Node
    By lmhelp2 in forum New To Java
    Replies: 1
    Last Post: 04-09-2010, 11:32 AM
  2. How "Pattern.matches(regex, input)" function works?
    By kishan in forum Advanced Java
    Replies: 2
    Last Post: 04-26-2009, 12:46 AM
  3. Regex Pattern/Matcher - Print only one occurrence!
    By racha0601 in forum Advanced Java
    Replies: 3
    Last Post: 04-06-2009, 05:05 PM
  4. Regex pattern
    By ravian in forum New To Java
    Replies: 4
    Last Post: 12-11-2007, 10:20 AM

Posting Permissions

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