***Need Regex for a 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.
Edited by: arjun2010 on Apr 26, 2010 9:36 PM

I'll let the fact that the requirement is very dodgy slide for a moment. It seems that a pattern might not be the solution here; why not do something like the following:
SWEEP 1:
- scan through the code one character at a time, looking for comment blocks and comment lines.
- remove all comment blocks from the code (or rather, copy all parts that are not comments to a new buffer)
now you have code cleaned of all comments
SWEEP 2:
- scan for 'noka.device.load' and extract those pieces of code with some clever string comparisons.
Of course I don't know the why behind this requirement, but if I had to implement such a crude requirement I'd do it as simple as possible in stead of as clean as possible.

Similar Messages

  • Regex for url pattern validation

    Hi,
    I am trying to find a regex for Url pattern validation that is not too restrictive.
    Please let me know, if anyone is using a pattern for their applications.
    Thanks
    Mayank Sharma

    are you talking about xml schema restriction?
    <xs:element name="url">
      <xs:simpleType>
       <xs:restriction base="xs:string">
        <xs:pattern value="(https?://)?[-\w.]+(:\d{2,5})?(/([\w/_.]*)?)?" />
       </xs:restriction>
      </xs:simpleType>
    </xs:element>

  • Regex for comma detection

    Hi,
    im trying to capture comma from a csv string, im unable to exclude the string having comma in between text part.
    eg 1)
    sample string-> 4,5656,123123,'this is sample text',''
    expected regex output->4{color:#ff0000},{color}5656{color:#ff0000},{color}123123{color:#ff0000},{color}'this is sample text'{color:#ff0000},{color}''
    eg2)
    sample string-> 4,5656,123123,'this is, sample text',''
    expected regex output->4{color:#ff0000},{color}5656{color:#ff0000},{color}123123{color:#ff0000},{color}'this is, sample text'{color:#ff0000},{color}''
    In above example the text containing comma in between of single quote is excluded
    Can anybody guide me through this(need regex for eg2)? Any kind of assistance would be priceless!!!

    Encephalopathic wrote:
    You may want to skip regex and look into using a Java csv parser which I heard exist in the public domain. I don't have any links but sourceforge and/or google can help.http://ostermiller.org/utils/CSV.html

  • How to search for a pattern string in entire registry and delete all the keys and subkeys that contain the pattern (C# or VB)?

    I want to search for a pattern string in the entire registry and need to delete all the keys and sub-keys that contain the pattern. How can I implement this in VB Script or C#? Appreciate if you can give some sample examples. Now every time, I am manually
    searching for the pattern in registry and deleting one by one.
    Thanks Prasad

    There is no built in way to do this. You'll end up having to enumerate all keys and values in the entire registry and comparing each one for a pattern using Regex or similar.  This is going to be really slow but there isn't much else you can do about
    it (other than parallelize the enumeration).  Also note that you won't have permissions to all keys for read and/or write access so you'll need to skip over those using exception handling.
    Michael Taylor
    http://blogs.msmvps.com/p3net

  • Regex for international character sets like [a-zA-Z] + �, Ł, �, etc.

    Hi all!
    Is there an internationalized equivalent for the pattern "[a-zA-Z]+" which would accept the French, German, Polish or other local characters like "&#321;" or "�" or "�"?
    It's a bad idea to add all of them to the standard regex like "[a-zA-Z���&#321;��]+", since you never know what comes next.
    I tried to use the "\\p{Alpha}+" to check the string "&#321;ukasz", but the string didn't match. Is there any other possibility other than to exclude "=", ">", "+", "�", etc.?
    Thanks for any help!
    Lena

    My application will get the UTF-8 encoded string and
    has to ensure it represents a valid name.There is no such thing as a "utf-8 encoded string." In Java strings are internally encoded in one of the 16-bit tranformation formats but you don't need to know this most of the time.
    The code you post works accidentally. It does not work in the general case. Just do what I said in my previous post.
    Try this code for instance:System.out.println(Charset.forName("UTF-8").encode(">8<>")
                         .asCharBuffer().toString().matches("\\p{L}+"));It will print "true" because the resulting charbuffer does match the pattern even though the original string does not. To understand why this happens I recommend reading the API documentation of the relevant classes.

  • Regex for RDF parsing

    Hi.
    I need help with parsing a rdf-format input stream. I want to use regex for parsing.
    The stream looks like this:
    <?xml version="1.0" encoding="ISO-8859-1" ?><rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns="http://my.netscape.com/rdf/simple/0.9/"><channel> <title>heise online news</title><link>http://www.heise.de/newsticker/</link><description>Nachrichten aus der Welt des Computers</description></channel><item><title>Scharfe Regeln f?r Chinas Cybercafes</title><link>http://www.heise.de/newsticker/data/gr-12.10.02-004/</link></item>.........</item></rdf:RDF>
    The information i need is placed between the <item></item> tags.
    I have wrote following code to get all subsequences like "<item>...</item>":
    String rval = new String("");
    Pattern p = Pattern.compile("<item[ >](.*)</item>");
    Matcher m = p.matcher(retval);
    while (m.matches()) {
    rval = rval + m.group() + "<br>\n";
    But this loop only once and the output is one large String from the first "<item>" to the last "</item>" like "<item>......</item><br>\n". The <item>...</item> combos within are ignored. Maybe the regex must be change?
    Thanks for answer,
    sushiprinz

    You need to use the non-greedy star:Pattern p = Pattern.compile("<item>(.*?)</item>");Also, I think you want to use find() instead of matches().

  • How can I use SQL to search for a pattern within a field?

    Hello, Frank, Solomon, ect
    I am now faced with this particular scenario, I've got the SQL to search through a field to find text within the field, but I have to know what it is before it can look for it.
    What I have to do is this:
    Search through a field, for a pattern, and I won't know what the data is I am looking for. Can this be done in SQL?
    For instance, Here is my SQL this far, I was helped allot in order to get to this point.
    select table_name,
           column_name,
           :search_string search_string,
           result
      from (select column_name,
                   table_name,
                   'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
              from cols
             where table_name in ('TABLE1', 'TABLE2')),
           xmltable (str columns result varchar2(10) path '.')
    When you execute the above SQL, you have to pass in a value. What I really need is to alter the above SQL, to make it search for a pattern that exist's within the text of the field itself.
    Like for instance, lets say the pattern I am looking for is this" xx-xxxxx-xxxx" and it's somewhere in a field.
    I need to alter this SQL to take this pattern and search through all the schemas and tables to look for this pattern match.
    Can be done?

    When you use something dynamically within a function or procedure, roles do not apply and privileges must be granted directly.  So, you need to grant select on dba_tab_cols directly.  If you want to do pattern matching then you should use regular expressions.  The following example grants the proper privileges and uses regexp_instr to find all values containing the pattern xxx-xxxx-xxxx, where /S is used for any non-space character.  I limited the tables in order to save time and output for the test, but you can eliminate that where clause.
    SYS@orcl> CREATE USER test IDENTIFIED BY test
      2  /
    User created.
    SYS@orcl> ALTER USER test QUOTA UNLIMITED ON USERS
      2  /
    User altered.
    SYS@orcl> GRANT CREATE SESSION, CREATE TABLE TO test
      2  /
    Grant succeeded.
    SYS@orcl> GRANT SELECT ON dba_tab_cols TO test
      2  /
    Grant succeeded.
    SYS@orcl> CONNECT test/test
    Connected.
    TEST@orcl> SET LINESIZE 90
    TEST@orcl> CREATE TABLE table1
      2    (tab1_col1  VARCHAR2(60))
      3  /
    Table created.
    TEST@orcl> INSERT ALL
      2  INTO table1 (tab1_col1) VALUES ('xxx-xxxx-xxxx')
      3  INTO table1 (tab1_col1) VALUES ('matching abc-defg-hijk data')
      4  INTO table1 (tab1_col1) VALUES ('other data')
      5  SELECT * FROM DUAL
      6  /
    3 rows created.
    TEST@orcl> CREATE TABLE table2
      2    (tab2_col2  VARCHAR2(30))
      3  /
    Table created.
    TEST@orcl> INSERT ALL
      2  INTO table2 (tab2_col2) VALUES ('this BCD-EFGH-IJKL too')
      3  INTO table2 (tab2_col2) VALUES ('something else')
      4  SELECT * FROM DUAL
      5  /
    2 rows created.
    TEST@orcl> VAR search_string VARCHAR2(24)
    TEST@orcl> EXEC :search_string := '\S\S\S-\S\S\S\S-\S\S\S\S'
    PL/SQL procedure successfully completed.
    TEST@orcl> COLUMN "Searchword"     FORMAT A24
    TEST@orcl> COLUMN "Table"     FORMAT A6
    TEST@orcl> COLUMN "Column/Value" FORMAT A50
    TEST@orcl> SELECT DISTINCT SUBSTR (:search_string, 1, 24) "Searchword",
      2               SUBSTR (table_name, 1, 14) "Table",
      3               SUBSTR (t.column_value.getstringval (), 1, 50) "Column/Value"
      4  FROM   dba_tab_cols,
      5          TABLE
      6            (XMLSEQUENCE
      7           (DBMS_XMLGEN.GETXMLTYPE
      8              ( 'SELECT ' || column_name ||
      9               ' FROM ' || table_name ||
    10               ' WHERE REGEXP_INSTR
    11                     (UPPER (' || column_name || '),''' ||
    12                  UPPER (:search_string) || ''') > 0'
    13              ).extract ('ROWSET/ROW/*'))) t
    14  WHERE  table_name IN ('TABLE1', 'TABLE2')
    15  ORDER  BY "Table"
    16  /
    Searchword               Table  Column/Value
    \S\S\S-\S\S\S\S-\S\S\S\S TABLE1 <TAB1_COL1>matching abc-defg-hijk data</TAB1_COL1>
    \S\S\S-\S\S\S\S-\S\S\S\S TABLE1 <TAB1_COL1>xxx-xxxx-xxxx</TAB1_COL1>
    \S\S\S-\S\S\S\S-\S\S\S\S TABLE2 <TAB2_COL2>this BCD-EFGH-IJKL too</TAB2_COL2>
    3 rows selected.

  • How do I create outlines for created pattern (or swatch) for laser cut?

    Hi,
    I can't figure out how to create outlines (vector lines) for my patterns , as I need to laser cut the pattern, and all the lines have to be seen,
    Please help!
    I use Illustrator CS6.

    mer,
    What happens if you Object>Expand?

  • Regex for a URL

    How do I write a regex for the following URL. I am trying to write a regex rule in Oracle WebCache.
    /myserver.domain.com:7779/mapviewer/mcserver?format=PNG&mapcache=mvdemo.demo_map&mx=198&my=247&request=gettile&zoomlevel=3
    Thanks,

    I would start with a not so restrictiv expression.
    something like
    SQL> with testdata as (select '/myserver.domain.com:7779/mapviewer/mcserver?format=PNG&mapcache=mvdemo.demo_map&mx=198&my=247&request=gettile&zoomlevel=3' urlstring from dual union all
      2                    select '/myserver.domain.com:7779/mapviewer/mcserver?format=PNG&mapcache=mvdemo.demo_map&mx=200&my=300&request=gettile&zoomlevel=180' urlstring from dual union all
      3                    select '/myserver.domain.com:7779/mapviewer/mcserver?format=PNG&mapcache=mvdemo.demo_map&my=300&mx=200&request=gettile&zoomlevel=0' urlstring from dual union all
      4                    select '/myserver.domain.com:7779/mapviewer/mcserver?format=PNG&mapcache=mvdemo.demo_map&mx=100&my=200&request=gettile' urlstring from dual union all
      5                    select 'somethingelse' urlstring from dual)
      6  select urlstring
      7  from testdata
      8  where regexp_like(urlstring,'^/myserver.domain.com:7779/mapviewer/mcserver[?]format=[PNG|SVG].+[mapcache=mvdemo.demo_map].+[request=gettile]');
    URLSTRING
    /myserver.domain.com:7779/mapviewer/mcserver?format=PNG&mapcache=mvdemo.demo_map
    &mx=198&my=247&request=gettile&zoomlevel=3
    /myserver.domain.com:7779/mapviewer/mcserver?format=PNG&mapcache=mvdemo.demo_map
    &mx=200&my=300&request=gettile&zoomlevel=180
    /myserver.domain.com:7779/mapviewer/mcserver?format=PNG&mapcache=mvdemo.demo_map
    &my=300&mx=200&request=gettile&zoomlevel=0
    /myserver.domain.com:7779/mapviewer/mcserver?format=PNG&mapcache=mvdemo.demo_map
    &mx=100&my=200&request=gettile
    SQL> In this example the url needs to include the mapcache, format and request parameter.
    Edited by: Sven W. on Oct 29, 2008 7:23 PM

  • Regex For Contractions/Possessives

    Hello,
    I'm trying to construct a regex for contractions and possessives.
    So, we want to validate strings like:
    'tis
    it's
    Travis'
    Ferdinand's
    However, I can't seem to get the regex to handle the apostrophe correctly...
    Here's what I have for regular contractions, (it's but not Travis' or 'tis)
    token.matches("[\\w]+'[\\w]+") What should I be doing differently?
    Thanks!
    Edited by: chhasx on Sep 1, 2009 2:42 PM

    You don't need the square brackets in this case. You shouldn't have + at the end of the second \w; there can be one or none, so it should be ?. Also it shouldn't be \w because it can only be "s". Also you're not covering the case "Travis's". Actually according to Strunk and White that's acceptable (preferred, IIRC) so maybe that's OK.
    You're not checking for "his", "her", "hers", or "its".
    This isn't internationalized either.

  • Help for image pattern matching

    Hello Everyone
    I am working for my last year project. In my project I will work on the image processing to find a moving object. I will work by JMF. I have finished to grab a frame from the webcam video clips. Now I need a algorithm to find a Image pattern from the grabed image. But I donot know which algorithm is fine for image pattern matching as well as how can I implement in java. Is anyone know please help me very urgently.
    Thank you
    Md. Mainul Hasan

    If you would like to take a look at http://www.exactfutures.com/index01.htm and http://www.exactfutures.com/index02.htm and http://www.codeproject.com/useritems/activity.asp then these pages and links may well be useful to you. It may not be exactly what you are looking for, but it does point to some examples with source for video analytics, and at the very least they illustrate how to capture & handle the data including a fast movement detection algorithm. If you want to find a specific shape then search the internet for information on chamfer distance transforms - one can use JMF or extend these simple examples to apply those techniques.

  • Regex for URL Validation

    HI I am validating a field which takes a url as input from the user.So the url may contain http,https,ftp links or the user may specify the ip address.So can anyone please help me out to create a suitable regex for that.I just need to check the validness of link and not that it exists or not.

    here i have changed the regex as suggested by you but
    it returns true even for http://com.com@
    which is invalid.
    So it did not worked :-(It did not work, because you did not use it correct:
    public class Foo {
        private static boolean isValidUrl(String url) {
            return url.matches("(https?|ftp)://www\\.\\w+\\.\\w+");
        public static void main(String[] args) {
            String[] urls = {
                    "http://com.com@",
                    "http://www.com.com",
                    "http://www.com.nl",
                    "http://www.com.co.uk",
                    "http://www.com"
            for(String url : urls) {
                System.out.println(url+" valid? "+isValidUrl(url));
    }

  • Regex for URL Expression

    I am not a programmer, but I have to write a rule for CACHING the following URL that is being generated with "GET_QUERYSTRING".
    /myserver.domain.com:7779/mapviewer/mcserver?format=PNG&mapcache=mvdemo.demo_map&mx=198&my=247&request=gettile&zoomlevel=3
    As you can see, I would like to cache all the PNG map tiles, but I don't know how to come up with Regular Expression (regex) for the above URL.
    Thanks,

    are you talking about xml schema restriction?
    <xs:element name="url">
      <xs:simpleType>
       <xs:restriction base="xs:string">
        <xs:pattern value="(https?://)?[-\w.]+(:\d{2,5})?(/([\w/_.]*)?)?" />
       </xs:restriction>
      </xs:simpleType>
    </xs:element>

  • Need help in finding patterns and there counts

    Hi All,
    I need help in finding patterns as well as number of occurrences of those patterns in a table's column's data.
    Consider sample data - one row's column from a table:
    "S-S-S-P-S-B-S-S-C-S-P"
    My requirement is:
    I should get all the patterns that are followed by 'S'.
    Example: for the above given data the patterns and counts are
    SS - count is 3
    SP - count is 2
    SB - count is 1
    SS - count is 1
    There is one more condition for the above requirement:
    If 'S' is followed by 'A', then 'SA' should not be considered as a pattern. The pattern should stretch until a non 'A' character is found.
    Consider sample data for the above case:
    "S-S-A-S-S-A-A-C-S-P-S-A"
    for the above given data the patterns and counts are
    SS - count is 2
    SP - count is 1
    SAS - count is 1
    SAAC - count is 1
    The data column is stored as VARCHAR2 type.
    I have Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    Thanks in advance,
    Girish G

    Hi, Girish,
    Girish G wrote:
    Hi All,
    I need help in finding patterns as well as number of occurrences of those patterns in a table's column's data.
    Consider sample data - one row's column from a table:
    "S-S-S-P-S-B-S-S-C-S-P"
    My requirement is:
    I should get all the patterns that are followed by 'S'.Do you mean "I should get all patterns that *start with* 'S'"?
    Example: for the above given data the patterns and counts are
    SS - count is 3
    SP - count is 2
    SB - count is 1
    SS - count is 1Why are there two rows of output for 'SS'? What does the second one, with count=1, mean?
    There is one more condition for the above requirement:
    If 'S' is followed by 'A', then 'SA' should not be considered as a pattern. The pattern should stretch until a non 'A' character is found.
    Consider sample data for the above case:
    "S-S-A-S-S-A-A-C-S-P-S-A"
    for the above given data the patterns and counts are
    SS - count is 2
    SP - count is 1
    SAS - count is 1
    SAAC - count is 1
    The data column is stored as VARCHAR2 type.
    I have Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit ProductionThanks; the version information is very helpful.
    Thanks in advance,
    Girish GWhenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
    For example, your sample data might be:
    CREATE TABLE     table_x
    (       x_id     NUMBER     PRIMARY KEY
    ,     txt     VARCHAR2 (30)
    INSERT INTO table_x (x_id, txt) VALUES (1, 'S-S-S-P-S-B-S-S-C-S-P');
    INSERT INTO table_x (x_id, txt) VALUES (2, 'S-S-A-S-S-A-A-C-S-P-S-A');and the results you want from that data might be:
    X_ID TXT                       PATTERN                          CNT
       1 S-S-S-P-S-B-S-S-C-S-P     SB                                 1
       1 S-S-S-P-S-B-S-S-C-S-P     SC                                 1
       1 S-S-S-P-S-B-S-S-C-S-P     SP                                 2
       1 S-S-S-P-S-B-S-S-C-S-P     SS                                 3
       2 S-S-A-S-S-A-A-C-S-P-S-A   SAAC                               1
       2 S-S-A-S-S-A-A-C-S-P-S-A   SAS                                1
       2 S-S-A-S-S-A-A-C-S-P-S-A   SP                                 1
       2 S-S-A-S-S-A-A-C-S-P-S-A   SS                                 2(This corresponds to what you posted, except that there is only one output row for 'SS' when x_id=1.)
    One way to get those results in Oracle 11 is:
    WITH   got_s_cnt    AS
         SELECT     x_id, txt
         ,     REGEXP_COUNT (txt, 'S')     AS s_cnt
         FROM     table_x
    ,     cntr          AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= (
                                   SELECT  MAX (s_cnt)
                             FROM    got_s_cnt
    ,     got_pattern     AS
         SELECT     s.x_id
         ,     s.txt
         ,     c.n
         ,     REGEXP_SUBSTR ( REPLACE ( SUBSTR ( txt
                                                 , INSTR (s.txt, 'S', 1, c.n)
                         , 'SA*[^A]'
                            )       AS pattern
         FROM    got_s_cnt  s
         JOIN     cntr        c  ON  c.n  <= s.s_cnt
    SELECT       x_id
    ,       txt
    ,       pattern
    ,       COUNT (*)     AS cnt
    FROM       got_pattern
    WHERE       pattern     IS NOT NULL
    GROUP BY  x_id
    ,            txt
    ,       pattern
    ORDER BY  x_id
    ,            pattern
    ;At the heart of this query is the call to REGEXP_SUBSTR:
    REGEXP_SUBSTR ( x
               , 'SA*[^A]'
               )which is looking for:
    S     = the letter S
    A*     = the letter A, repeated 0 or more times
    [^A]     = anything except the letter A

  • Program for designing patterns for fabric

    I need advice on which program would be best for designing patterns to then use for fabric printing, wall paper etc.
    I am a complete adobe novice.
    Thanks,
    Kim

    Hi kimtreasure,
    For designing you can use Adobe Illustrator and Adobe Photoshop.
    For more info:
    Photoshop : Adobe Photoshop CC new features | Buy Photoshop CC
    Illustrator : Adobe Illustrator CC new features | Buy Illustrator CC
    Download trial version.
    Creative Cloud Help | Install, update, or uninstall apps
    Thanks,
    Atul Saini

Maybe you are looking for

  • Pasting text into a text layer in Photoshop CC 2014

    I've been playing around around with Photoshop CC 2014 HTML5/Javascript extensions (CEP5) for a while now and I came across a problem I couldn't solve: how to paste text in an existing text layer when the user is editing the text? Using evalScript an

  • Creating "Back" Navigation in a Branching Project Without the Playbar or a TOC?

    Hello, I've been struggling with accomplishing a very simple goal: in my Captivate project, I want there to be a "Back" button on every single slide that sends the user back one slide based on their navigation history throughout the slide.  The playb

  • Slow Connection

    Hi, i have just recently started experiencing a slow adsl connection. For 5 years i have had no real problems except random diconnections, until recently.For the last week my connection has dropped from a 1500kb/s connection to roughly a 256k connect

  • Dump with ORA-01438: value larger than specified prec

    Hello All, I am getting a dump in production with the above said error and the ST22 gives me further analysis that "If the error occurred in Open SQL, there is probably an inconsistency between the NAMETAB and the ABAP/4 Dictionary.                  

  • Unable to Open SBWP - short Dump

    Hi, I have a problem with my SBWP - I'd be experiencing runtime error (Time_out). It says time limit exceeded - and that the program 'SAPFSSO0' has exceeded the maximum permitted runtime without interruption and has therefore been terminated. Can any