IBM Guardium

IBM Guardium

Join this online user group to communicate across Security product users and IBM experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Regex to search for six-digit numbers in quotes

  • 1.  Regex to search for six-digit numbers in quotes

    Posted Tue July 16, 2024 09:23 AM

    Hello dear friends,

    I'm trying to create a report and I'm stuck, so I'm looking for someone who had a similar use case and managed to solve it.

    So, I would like to create a report that retrieves the FULL SQL records, but only those records that contain exactly 6 USER DEFINED/VARIABLE digits.

    For example, I want a user to be able to search for: 448957 and only get records that contain exactly that number, but not let's say this record:



    in the "Conditions" section I created 2: 

    but it looks like i'm doing something wrong.

    If i set for regex ".*" and for FULL SQL Values "%" i get all the results. But when I try to filter them I can never successfully get what I'm looking for.

    I tried the following regexes:

    Regex

    Output

    ^(.*)?(\B\d{6}\B)?(.*)

    for some reason it returns records that have 10 digit numbers as well

    ^.*[^0-9]([9-9][0-9][0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9][0-9])[^[0-9].*$

    returns multi-digit if they contain the required six-digit number

    ^(.*)(\d{6})(.*)

    no result

    ^(.*)?(\d{6})?(.*)

    returns multi-digit if they contain the required six-digit number

    .*\d{6}.*

    there are no results, but there should be

    ^(\d{6}(\d))$

    there are no results, but there should be

    ^(\d{6})$

    there are no results, but there should be

    (?s).*?\d{6}.*?

    error (repetition-operator operand invalid)

    (.|\n)*\d{6}(.|\n)*

    there are no results, but there should be

    (?:.|\n)*\d{6}(?:.|\n)*

    error (repetition-operator operand invalid)

    ^([\s\S]*)(\d{6})([\s\S]*)$

    there are no results, but there should be

    with the value parameter "%" to retrieve all records containing six-digit numbers.

    Also, I wonder if there is some way to search for numbers inside single quotes?

    For example: '448957'

    By default, Guardium forbids the use of the characters --, ' and '' - probably as a protection mechanism against SQL injection, but I'm interested in whether there is still a solution for searching the specified string, for example: ACCOUNTNUMBER = '448957'

    Kind Regards,
    Filip