Calling all regex masters

All,
I am trying to meet a requirement where the user can use regular expression like entries to filter data. For instance if the input was "1-4,6" then the user would get records containing 1,2,3,4,6. I tried wrapping the input in brackets and sending it through regexp_instr, however it does not work with multiple digits.
with test_data as(
  SELECT level data
    FROM DUAL
CONNECT BY LEVEL <= 10
SELECT data
  FROM test_data
WHERE regexp_instr(data, '[1-4,6]',1,1,0,'i') > 0
-- returns 1,2,3,4,6,10
-- the 10 should not be thereI changed the code by adding the start of string and end of string modifier but its still not quite right.
with test_data as(
  SELECT level data
    FROM DUAL
CONNECT BY LEVEL <= 10
SELECT data
  FROM test_data
WHERE regexp_instr(data, '^[1-4,6,10]$',1,1,0,'i') > 0
-- returns 0,1,2,3,4,6but now if i want to find a 10 it will only look for 1 or 0 not "10".
Any suggestions on how to accomplish this with regular expressions or any other method of reaching the same functionality?
Cheers,
Tyson Jouglet

All,
After realizing that regular expressions get exponentially complicated as you add more digits i decided to ditch that effort and dynamically built the where clause. In short I replaced the "1-4" with a between statement and added all none range inputs into an IN statement
here is the first go around of the code:
create or replace
function createWhereClause(p_string varchar2
                          ,p_column varchar2
                          ,p_delim varchar2 default ',')
return varchar2
deterministic
is
  l_or        varchar2(4)      := ' OR ';
  l_crlf      varchar2(2)      := chr(13)||chr(10);
  l_output    varchar2(32000);
  l_index     pls_integer;
  l_bet_index pls_integer      := 0;
  l_ins_index pls_integer      := 0;
  l_tokens    wwv_flow_global.vc_arr2;
  l_betweens  wwv_flow_global.vc_arr2;
  l_ins       wwv_flow_global.vc_arr2;
begin
  l_tokens := htmldb_util.string_to_table(p_string,p_delim);
  l_index := l_tokens.first;
  while l_index is not null loop
    if instr(l_tokens(l_index),'-') > 0 then
      l_bet_index := l_bet_index + 1;
      l_betweens(l_bet_index) := p_column || ' BETWEEN ' ||replace(l_tokens(l_index),'-',' AND ');
    elsif l_tokens(l_index) is not null then
      l_ins_index := l_ins_index + 1;
      l_ins(l_ins_index) := l_tokens(l_index);
    end if;
     l_index := l_tokens.next(l_index);
  end loop;
  l_index := l_betweens.first;
  while l_index is not null loop
    l_output := l_output || l_betweens(l_index) || l_or || l_crlf;
    l_index  := l_betweens.next(l_index);
  end loop;
  l_index := l_ins.first;
  if l_index is not null then
    l_output := l_output || p_column || ' IN (';
    while l_index is not null loop
      l_output := l_output || l_ins(l_index) || ',';
      l_index  := l_ins.next(l_index);
    end loop;
    l_output := rtrim(l_output,',') || ')';
  end if;
  return rtrim(l_output,l_or);
end;Cheers,
Tyson Jouglet

Similar Messages

  • Calling all GUI Masters....

    I have searched and searched for this topic on the internet and I can't seem to find anything on it. I would like to have a column of JProgressBars in my JTable. I know that I need to create a cell renderer for this and I did. The progress bars show up in my table. However, I want to update the progress bars individually just one time (I don't need to use any new threads to update it constantly). What happens is that I'm trying to get a value, say 80 and based on that value, I set the progress bar color to a specific.color...say green...when I do this it sets ALL of the progress bars to that color when I only want one of the progress bars to turn green.
    Does anyone have a clue at all how I could do this? I know that the method getTableCellRenderComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) is used to change the color of the progress bar, but what does the parameter Object value refer to...I'm having trouble getting the value to compare from my other class and then comparing it and setting the proper row to the appropriate color. Anyone have any ideas? Essentially this is what I want to do in pseudocode form
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
    if the value computed is >= 75, then I want to color that progress bar row with that value green
    if value >= 25 && <= 50 color that progress bar yellow
    if value <=25 color that progress bar red
    return this;
    I think you get the idea. Please help!

    ok...here's my code
    //table model
    import java.awt.Component;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    public class BordersTableModel extends DefaultTableModel
         public BordersTableModel()
              super();
         public BordersTableModel(Object[] columnNames, int rowCount)
              super(columnNames, rowCount);
         public boolean isCellEditable(int row, int column)
              return false;
    //ProgressBarRenderer
    public class ProgressBarRenderer extends JProgressBar implements TableCellRenderer
    protected TableCellRenderer delegate;
         JProgressBar bar;
         public ProgressBarCellRenderer(TableCellRenderer defaultRenderer)
              super(JProgressBar.HORIZONTAL);
              setBorderPainted(false);
              setBorder(null);
              this.delegate=defaultRenderer;
              UIManager.put("ProgressBar.selectionForeground", Color.BLACK);
              UIManager.put("ProgressBar.selectionBackground", Color.BLACK);
         bar=new JProgressBar();
         public void setValue(int aValue)
              bar.setValue(aValue);
         public Component getTableCellRendererComponent(JTable table, Object value,
                   boolean isSelected, boolean hasFocus, int row, int column)
              bar.setStringPainted(true);
              if(bar.getValue()>=75)
                   bar.setForeground(Color.GREEN);
              if( (bar.getValue()> 25) && (bar.getValue() <= 50) )
              bar.setForeground(Color.YELLOW);
              if(bar.getValue() <= 25)
                   bar.setForeground(Color.RED);
              if( (bar.getValue() > 50 ) && (bar.getValue() < 75))
                   bar.setForeground(Color.ORANGE);
              return bar;
    //CombinedInterface where all the listeners and GUI stuff is
    public class CombinedInterface
    ProgressBarRenderer progressRend=new ProgressBarRenderer();
    BordersTableModel model=new BordersTableModel(columnNamesStr, 0);     
    table=new JTable(model);
    table.setDefaultRenderer(JProgressBar.class, progressRend);
    TableColumn column=table.getColumnModel().getColumn(0);
    column.setCellRenderer(progressRend);
    searchJB.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
                   try
                             progressRend.setValue(65);     
                        catch(ArithmeticException math)
                             System.err.println("No results were found");
                             System.err.println();
    so If I understand you correctly, I need to add the following method to my table model
    public void setValueAt(Object aValue, int row, int column)
    super.setValueAt(aValue, row, column);
    so when I call getTableCellRendererComponent, it gets the args value, row, and column from my table model?
    Stephen

  • IPhone 5S: does anybody has this problem. During a successful voice call all of a sudden people can't hear me while I can hear them

    iPhone 5S: does anybody has this problem. During a successful voice call all of a sudden people can't hear me while I can hear them. Signal is strong and call quality (me hearing the other) is still very good but it looks as if I’m going on mute while I’m not muting my iPhone. When dropping the call and re-dialing it works fine again. It’s a brand new iPhone 5S but it now happened already 4 or 5 times in 2 days.
    It feels like a hardware/iOS problem and not a network issue. It happend with iOS7.03 but I just see 7.0.4 is available so will install that one now.
    Thanks in advance for feedback
    Best regards,
    Marco

    Hello Jeff,
    Thank you for providing so much detail about the issue you are experiencing with the audio on your iPhone.  I would be concerned too if the audio on my iPhone was not working unless using speaker phone.  I found an article with some steps to take when you are experiencing issues like this:
    iPhone: Can't hear through the receiver or speaker
    http://support.apple.com/kb/TS1630
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • I delete some emails ,there are moved to trash . I delete them from trash folder too and they still appear in a folder called 'all messages". I repeat the same actions and after a while they appear again!what should i do to delete them permanently??

    I delete some emails ,there are moved to trash . I delete them from trash folder too and they still appear in a folder called 'all messages". I repeat the same actions and after a while they appear again!what should i do to delete them permanently??

    If you are using Apple's Mail app 6.5 is the latest version irrespective of what a previous poster says. It does sound though that you are using a gmail account online via a web browser. Please confirm and fill in missing information.

  • TS1702 I have an iphone and my 2 children have ipods.  all 3 on the same apple id.  when one of their ipods gets a face time call , all 3 devices ring. i dont want to get these face time calls on my iphone or the other ipod .  what is the solution to this

    i have an iphone and my 2 children have ipods. all 3 on the same apple id.  when one ipod gets a facetime call, all 3 devices ring.  how do i prevent all three devices getting the facetime call as it is intended for only one of the ipods?

    You can all have independent AppleIDs for iCloud or iMessage etc, but share the same one for iTunes Store / AppStore purchases.

  • After a recent update, the Bookmarks menu has an extra folder called "All Bookmarks" which appears to be a copy of the bookmarks. It is causing problems and how do I fix it?

    I recently updated Firefox. The Bookmarks menu shows a new menu item called "All Bookmarks". It appears to be a copy of the bookmarks. When I try to add a new bookmark, the All Bookmarks folder is the only one shown in the dialog. I tried deleting the All Bookmarks folder, but then nothing is shown in the dialog when I try to add a new bookmark.
    If I do add a new bookmark, it is put under the All Bookmarks folder and does not show up under the top-level item I want it under. Any ideas about what I can do to fix this.
    The update went normally without my intervention.
    Thanks

    I was able to fix the problem after following the bookmark backup and restore procedures on the following page:
    http://kb.mozillazine.org/Locked_or_damaged_places.sqlite#Problems_limited_to_bookmarks
    I also had to restart Firefox so that the "Bookmark This Page" dialog would show the normal bookmarks.
    Thanks.

  • Calling all Dell L501X owners! [Solved]

    Calling all Dell L501X owners! Specifically the i7 with Nvidia GT435
    Can anyone  comment on if they are having any issues running dual monitors with KDE?
    My issue is that the 'org.kde.powerdevil.backlighthelper' is called randomly and switches the displays LVDS + DP1 between cloned and singular when I've had it set to extended via both TwinView and randr.
    I'm now running XFCE without problems but its bugging me that I can't use KDE.
    My initial post was placed here https://bbs.archlinux.org/viewtopic.php?id=162545 but I have created this to try and find where the peculiarities lie. I'm connected to a Dell U2311 monitor via DisplayPort
    Last edited by Hutchism (2013-05-30 14:27:20)

    Problem fixed now as mentioned in other post. Seems that it doesn't like the function keys been set to default as opposed to the media keys in the BIOS settings. Hope this helps someone in the future. Surprised no-one else has run across this problem.
    If anyone know of a fix for this would be appreciated. Save me from doing yoga with my fingers when trying to do simple keyboard shortcuts. Currently using latest Dell BIOS "A04" (http://www.dell.com/support/drivers/us/ … erId=K5CNF)
    Last edited by Hutchism (2013-05-30 11:12:17)

  • SQLException: After clearParameters() has been called, all parameters must be reset before executing

    Hi,
    I am running: Weblogic 6.1, SP2
    Driver : weblogic.jdbc.oci.Driver
    Reason for not using the "thin" driver, which works, is limit
    on size of Clob
    Previous references to this problem in this newsgroup indicate driver problems
    with older versions of WL.. I am using the latest..
    The SQLException I get is "After clearParameters() has been called, all parameters
    must be reset before executing". This happens the second time the code below is
    excuted ( ok the first time )
    "clearParameters()" is never called explicitly in my code.
    The exception occurs on the "spFunc.execute();" statement at the very end of this
    code:
    // OBS:connection, conn_, is opened from a connection pool
    before this code is called and cloesed afterwards.
    conn_.setAutoCommit(false);
    // ============== Initializing clob ==================
    SerialStatement stmt = (SerialStatement)conn_.createStatement();
    stmt.execute("INSERT INTO lc_clob_temp VALUES (1, EMPTY_CLOB())");
    // OBS: using a prepared statement here will result in SerialClob
    // exception when using setClob in the prepared statement
    below
    // This is probably a bug ( worked in WL 5.1 ). We had this
    as a support case 270952 with WebLogic.
    stmt.execute("SELECT * FROM lc_clob_temp WHERE id = 1");
    ResultSet crs = stmt.getResultSet();
    weblogic.jdbc.rmi.SerialClob xmlClob = null;
    while ( crs.next() ) {
    xmlClob=(weblogic.jdbc.rmi.SerialClob)crs.getClob("newclob");
    // Call Oracle's stored procedure for calling Oracle XSU.
    SerialCallableStatement spFunc =
    (SerialCallableStatement)conn_.prepareCall(
    "declare " +
    "insCtx sys.DBMS_XMLSave.ctxType; " +
    "begin " +
    "insCtx := sys.DBMS_XMLSave.newContext(?); " +
         "sys.DBMS_XMLSave.setBatchSize(insCtx,0);" +      "sys.DBMS_XMLSave.setCommitBatch(insCtx,
    0);" +
    "? := sys.DBMS_XMLSave.insertXML(insCtx,?); " +
    "sys.DBMS_XMLSave.closeContext(insCtx); " +
    "end;"
    spFunc.setString(1, viewName );
    spFunc.registerOutParameter (2, Types.NUMERIC);
    Writer outstream = xmlClob.getCharacterOutputStream();
    outstream.write(xml.toString());
    outstream.flush();
    outstream.close();
    spFunc.setClob( 3, xmlClob);
    spFunc.execute();
    spFunc.close();

    Hi,
    I am running: Weblogic 6.1, SP2
    Driver : weblogic.jdbc.oci.Driver
    Reason for not using the "thin" driver, which works, is limit
    on size of Clob
    Previous references to this problem in this newsgroup indicate driver problems
    with older versions of WL.. I am using the latest..
    The SQLException I get is "After clearParameters() has been called, all parameters
    must be reset before executing". This happens the second time the code below is
    excuted ( ok the first time )
    "clearParameters()" is never called explicitly in my code.
    The exception occurs on the "spFunc.execute();" statement at the very end of this
    code:
    // OBS:connection, conn_, is opened from a connection pool
    before this code is called and cloesed afterwards.
    conn_.setAutoCommit(false);
    // ============== Initializing clob ==================
    SerialStatement stmt = (SerialStatement)conn_.createStatement();
    stmt.execute("INSERT INTO lc_clob_temp VALUES (1, EMPTY_CLOB())");
    // OBS: using a prepared statement here will result in SerialClob
    // exception when using setClob in the prepared statement
    below
    // This is probably a bug ( worked in WL 5.1 ). We had this
    as a support case 270952 with WebLogic.
    stmt.execute("SELECT * FROM lc_clob_temp WHERE id = 1");
    ResultSet crs = stmt.getResultSet();
    weblogic.jdbc.rmi.SerialClob xmlClob = null;
    while ( crs.next() ) {
    xmlClob=(weblogic.jdbc.rmi.SerialClob)crs.getClob("newclob");
    // Call Oracle's stored procedure for calling Oracle XSU.
    SerialCallableStatement spFunc =
    (SerialCallableStatement)conn_.prepareCall(
    "declare " +
    "insCtx sys.DBMS_XMLSave.ctxType; " +
    "begin " +
    "insCtx := sys.DBMS_XMLSave.newContext(?); " +
         "sys.DBMS_XMLSave.setBatchSize(insCtx,0);" +      "sys.DBMS_XMLSave.setCommitBatch(insCtx,
    0);" +
    "? := sys.DBMS_XMLSave.insertXML(insCtx,?); " +
    "sys.DBMS_XMLSave.closeContext(insCtx); " +
    "end;"
    spFunc.setString(1, viewName );
    spFunc.registerOutParameter (2, Types.NUMERIC);
    Writer outstream = xmlClob.getCharacterOutputStream();
    outstream.write(xml.toString());
    outstream.flush();
    outstream.close();
    spFunc.setClob( 3, xmlClob);
    spFunc.execute();
    spFunc.close();

  • Call all instances of a symbol

    Hej,
    i need to place 10 different kinds of symbols, a hundred times each on my stage. Theses symbols have the same shape, but different colors. I need to filter them out in a tiny top-menu.
    So, if i click e.g. on a red circle, i want all non red symbols to set there opacity to 0.5.
    It could be simple if i place all red symbols into a container "$color-symbols" and set the opacity to them. But that is not possible, because I need to place each symbol manually. And if they are childs of another symbol, drag and drop is horrible.
    Now i am wondering if it is possible to call all symbols on stage that are instances of a symbol in my library.
    And is there a nice way to call "all-other-colors" instead of
    sym.$("color-1").animate({opacity:0.5},500);
    sym.$("color-9").animate({opacity:0.5},500);
    sym.$("my-own-color").animate({opacity:1},500);
    on every button on stage?

    Thanks for your help,
    i use the classes to specify a target url for each symbol.
    For Example:
    I have three red symbols and three blue symbols.
    The classes for the red-ones are:
    33451, 56789 and 45678
    for the blue ones:
    983, 4, 1002
    Inside of my symbols i have a script:
    var names = (e.target.id).split("_");
    var page = names[2];
    var link = "http://www.url.no/subpage/"+page;
    window.open(link, "_self");
    If i find another way to put a specific ID (and it must be a number) on to each Instance, i could use the way you describe.
    Because your idea is to use the class-names, there is no way to call all instances of a given symbol?
    Is it possible to use wildcards for my array?
    So i could name them "red-33451#1", "red-56789#2", "red-45678#3". And cut out everything between "-" and "#".
    But remember that i need to place a few hundreds of them, which isn't fun. And if i need to insert one later or if i delete another one, i need to verify all my functions.

  • Call all elements with similar id in symbol

    Hi,
    I use this
    var text = $("[id*='Text']");
    for call all of elements says Text1_01, Text1_02, Text2_01,....
    And this works perfectly but when the elements are in a symbol this don't work.
    Why?
    How i can do this variable?
    Thanks

    var text = sym.getSymbol('symbolname'). $("[id*='Text']");
    This ignore me and selection all of "Text" out of symbols
    var all = sym.getChildSymbols(). $("[id*='Text']");
    And this ignore all of "Text"

  • Calling all Matrox Millenium G550 graphics cards...

    Calling all Matrox Millenium G550 graphics cards...
    Has ANYONE got the Cover Flow view working with this card?
    If you have you have what did you do (if anything)?
    I've already tried:-
    * the latest Matrox drivers
    * the latest DirectX
    * ensuring that Hardware Acceleration is at Full
    * uninstall & re-install iTunes
    * install latest Quicktime before re-installing iTunes
    P4 2GHz, 1GB RAM   Windows XP Pro   SP2; Matrox G550; Dual screen

    At home, I have a Matrox Parhelia and the cover flow mode works great. I have a G550 in my work computer but I don't have any music local on the hard drive. I use my iPod Photo as axteranal HD to play via iTunes. So, cover art doesn't show up.
    However, I have brought to work some hummingbird videos that took last week and added them to the Movie section in Itunes on my Work PC. So, I tried cover flow in the movie mode. It looks awful! Each picture is made up of little pictures in a 18x9 mosaic. I can even see though the gaps where there are grid lines. I don't see this at home with the Parhelia.
    I have the latest everything installed as well. I'm running WinXP SP2. Have you found a solution?
    Thanks,
    Steven

  • Hi All QM Masters, Urgent

    Dear All QM Masters,
    Can any body tell me tha in Qa 32 if Lot status is REL CALC, but message is result recording is not possible. then what may the error in the settings.
    Thanks and Regards,
    Neeraj

    Hi
    please explain in detail what is error message you are getting with message number? what is inspection lot status (all).
    also please check material master whether inspection with task list flagged or not in quality view.
    regards
    Srinivas

  • When i make calls, all i can hear is static, and when i plug in headphones or turn the speaker on, it still doesnt work. but facetime, music, an apps sound still work. help? iphone 5

    when i make calls, all i can hear is static, and when i plug in headphones or turn the speaker on, it still doesnt work. but facetime, music, an apps sound still work. help? iphone 5

    Hello Delaney1130,
    It sounds like you are getting static on both the receiver and the speaker when you make a call. I would use the troubleshooting from the following article to help resolve the issue named:
    iPhone: Troubleshooting issues making or receiving calls
    https://support.apple.com/kb/TS3406
    Toggle airplane mode: Tap Settings > Enable Airplane Mode, wait five seconds, then turn off airplane mode.
    Check your phone settings:
    Check your Do Not Disturb settings: Tap Settings > Do Not Disturb.
    Check for any blocked phone numbers: Tap Settings > Phone > Blocked.
    See if Call Forwarding is turned on: Tap Settings > Phone > Call Forwarding.
    Ensure that your software is up to date:
    Check for a carrier settings update.
    Check for an iOS software update.
    Note: Some updates may require a Wi-Fi connection.
    If the iPhone has a SIM card, reseat the SIM card.
    If the iPhone 4 or iPhone 4s is on the Verizon network, dial *228 from the iPhone and select option 2 to update the Preferred Roaming List (PRL). The PRL determines the cellular towers the phone uses for cellular service, selecting those with the best signal strength.
    Reset the network settings: Tap Settings > General > Reset > Reset Network Settings.
    Try to make or receive calls in another location.
    Attempt to isolate to one network band:
    If you're having the issue on LTE, disable LTE, if possible, and try again.
    If you're having the issue on 3G/4G, disable 3G/4G, if possible, and try again.
    Contact the carrier to check the following:
    Your account is properly configured to use the specific iPhone that has the issue.
    There are no localized service outages.
    Your account doesn't have a billing-related block.
    Your calls don't have errors on the carrier system.
    Restore the phone as new.
    If the above steps don't resolve the issue, go to an Apple Retail Store, carrier, Apple Authorized Reseller, or contact AppleCare to send the phone in for service.
    Thank you for using Apple Support Communities.
    All the very best,
    Sterling

  • When someone calls all the IPhones in the house ring, what is wrong?

    When someone calls all the IPhones in the house ring, what is wrong.

    You share the same Apple ID and in iOS 8 there is a new feature, which if you didn't share the same ID, you can answer a call on another device if one is another room as long as they are both on iOS 8.  To stop this, go to Settings > Facetime and turn off iPhone Cellular Calls.  That will stop this for you.

  • Iphoto deleted all my masters, any way to recover them? PLEASE HELP!!

    Iphoto deleted all my masters and I cant seem to find them, is there any way to recover them? Iphoto 11 version. The only pictures that are left are some previews and some thumbnails.

    Try the following:
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    Download iPhoto Library Manager and launch.
    Click on the Add Library button, 
    navigate to your Home/Pictures folder and select your iPhoto Library folder.
    Now that the library is listed in the left hand pane of iPLM, click on your library and go to the Library ➙ Rebuild Library menu option
    In the next  window name the new library and select the location you want it to be placed.
    Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments. However, books, calendars, cards and slideshows will be lost.
    Note:  your current library will be left untouched for further attempts at a fix if so desired.
    If that fails continue with:
    Starting over from scratch with new library
    Start over with a new library and import the Originals (iPhoto 09 and earlier) or the Masters (iPhoto 11) folder from your original library as follows:
    1. Open the library package like this.
    2. Launch iPhoto with the Option key held down and, when asked, select the option to create a new library.
    3. Drag the subfolders of the Originals (iPhoto 09 and earlier) or the Masters (iPhoto 11) folder from the open iPhoto Library package into the open iPhoto window a few at a time.
    This will create a new library with the same Events (but not necessarily the same Event names) as the original library but will not keep the metadata, albums, books slideshows and other projects.
    Note:  your current library will be left untouched for further attempts at a fix if so desired.
    OT

Maybe you are looking for