Topic
  • 8 replies
  • Latest Post - ‏2013-02-15T12:45:39Z by Jayatheerthan
SystemAdmin
SystemAdmin
603 Posts

Pinned topic AQL Regular Expressions

‏2013-02-15T04:57:21Z |
Hi,

I have a text file with 3 columns like Id,Name,Description.
For Example,

219;John;He is a good swimmer.
289;Paul;He is a good dancer.
123;David;He is a good writer.

Now I have written view for column "Id" using general regular expression for numbers without using dict file.

create view RefId as
extract regex /^0-9+$/ on D.text as num
from Document D;
output view RefId;

But it displaying error "There are no annotations in the input collection".

Could anyone solve my problem??
Updated on 2013-02-15T12:45:39Z at 2013-02-15T12:45:39Z by Jayatheerthan
  • Jayatheerthan
    Jayatheerthan
    20 Posts

    Re: AQL Regular Expressions

    ‏2013-02-15T05:16:53Z  
    Use the regex /(?m)0-9+/
  • Jayatheerthan
    Jayatheerthan
    20 Posts

    Re: AQL Regular Expressions

    ‏2013-02-15T05:18:39Z  
    Use the regex /(?m)0-9+/
    Oops - the square brackets were skipped by the dWForum editor as it mistook square brackets to be a part of the wiki syntax!

    The regex that I intended to type was
    
    /(?m)[0-9]+/ 
    
  • Jayatheerthan
    Jayatheerthan
    20 Posts

    Re: AQL Regular Expressions

    ‏2013-02-15T05:35:07Z  
    Oops - the square brackets were skipped by the dWForum editor as it mistook square brackets to be a part of the wiki syntax!

    The regex that I intended to type was <pre class="jive-pre"> /(?m)[0-9]+/ </pre>
    One word of caution though:

    The regex (?m) will technically work and will help you to see the expected results, but might run slower as it is not compatible with Text Analytics engine's accelerated regex engine.
  • SystemAdmin
    SystemAdmin
    603 Posts

    Re: AQL Regular Expressions

    ‏2013-02-15T05:45:06Z  
    One word of caution though:

    The regex (?m) will technically work and will help you to see the expected results, but might run slower as it is not compatible with Text Analytics engine's accelerated regex engine.
    Hi,

    Thanks for the quick response but the problem I was facing that the regular expression is working fine , the thing is that the numbers in the description are also getting displayed. But I want only the Reference column records to be displayed.
  • Jayatheerthan
    Jayatheerthan
    20 Posts

    Re: AQL Regular Expressions

    ‏2013-02-15T06:34:41Z  
    Hi,

    Thanks for the quick response but the problem I was facing that the regular expression is working fine , the thing is that the numbers in the description are also getting displayed. But I want only the Reference column records to be displayed.
    If you want to pick the numbers that appear at the begin of a line, then use the following:

    
    /(?m)^[0-9]+/ 
    


    (?m) is multi line mode
    ^ to match at begin of line
  • SystemAdmin
    SystemAdmin
    603 Posts

    Re: AQL Regular Expressions

    ‏2013-02-15T12:03:10Z  
    If you want to pick the numbers that appear at the begin of a line, then use the following:

    <pre class="jive-pre"> /(?m)^[0-9]+/ </pre>

    (?m) is multi line mode
    ^ to match at begin of line
    Thanks it worked
  • SystemAdmin
    SystemAdmin
    603 Posts

    Re: AQL Regular Expressions

    ‏2013-02-15T12:30:11Z  
    Thanks it worked
    I want to pick the numbers from middle of the line, could u tell me the regular expression for that?
  • Jayatheerthan
    Jayatheerthan
    20 Posts

    Re: AQL Regular Expressions

    ‏2013-02-15T12:45:39Z  
    I want to pick the numbers from middle of the line, could u tell me the regular expression for that?
    The following links would be of great help to write regexes:

    Oracle's documentation : Link: http://docs.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html

    Java Regex tutorial : Link: http://www.vogella.com/articles/JavaRegularExpressions/article.html

    Documentation on Regex support in InfoSphere BigInsights Text Analytics: Link: http://pic.dhe.ibm.com/infocenter/bigins/v2r0/topic/com.ibm.swg.im.infosphere.biginsights.text.doc/doc/biginsights_aqlref_ref_regular-expressions.html