Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9032589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:01:02+00:00 2026-06-16T08:01:02+00:00

Problem : Regular expression not working as expected for HBase scan filter. Although this

  • 0

Problem : Regular expression not working as expected for HBase scan filter.
Although this RegEx passes without any error it doesn’t return filtered rows only.

Background :
We are storing our data in HBase as string (I know it should have been in Avro but need to work with this now.)

Our HBase column DataRows look something like below, pipe is used as delimiter.

NAME|10000081|10000102|13513|10102026|GENDER|ID
NAME|10000081|10000101|13513|10102026|GENDER|ID
NAME|10000081|10000103|13513|10102026|GENDER|ID
NAME|10000082|10000104|13515|10102026|GENDER|ID
NAME|10000082|10000104|13516|10102026|GENDER|ID

I am writing a RegEx filter for the HBase scanner which will scan these rows.

My RegEx string looks like this :

^NAME\\|.*\\|.*\\|.*\\|.*\\|.*\\|.*$

This is input for HBase QualifierFilter, e.g

Filter qfilter = new QualifierFilter(CompareFilter.CompareOp.EQUAL,new RegexStringComparator(regexString.toString()));

In above example for regex string (I want to filter only Name=RECKO and 3rd col = 10000101).
It returns all rows.

Regex String = ^NAME\\|.*\\|10000101\\|.*\\|.*\\|.*\\|.*$

What is wrong with my regular expression? Any pointers/suggestions are appreciated very much.

Test Program:

 public class RegEx1 {
      public static void main(String[] args) {
        String Str[] = {
        "PC|10000081|10000102|13513|10102026|LOC|ic",
        "PC|10000081|10000101|13512|10102025|LOC|zc",
    "NAME|10000042|10000084|13576|10101626|GENDER|cc",
    "NAME|10000042|10000084|13576|10101626|GENDER|za",
    "NAME|10000042|10000084|13576|10101626|GENDER|zc",
    "NAME|10000061|10000086|13581|10101630|GENDER|ic",
    "NAME|10000061|10000086|13581|10101630|GENDER|za",
    "NAME|10000061|10000086|13581|10101630|GENDER|zc",
    "NAME|10001076|10001744|15106|10123669|GENDER|cc",
    "NAME|10001076|10001744|15106|10123669|GENDER|za",
    "NAME|10001076|10001744|15106|10123669|GENDER|zc",
    "NAME|10000061|10000086|13581|10101630|GENDER|ic",
    "NAME|10000061|10000086|13581|10101630|GENDER|za",
    "NAME|10000061|10000086|13581|10101630|GENDER|zc",
    "NAME|10001075|10001743|15105|10123664|GENDER|ic",
    "NAME|10001075|10001743|15105|10123664|GENDER|za",
    "NAME|10001075|10001743|15105|10123664|GENDER|zc",
    "NAME|10001077|10001745|15239|10123673|GENDER|cc",
    "NAME|10001077|10001745|15239|10123673|GENDER|za",
    "NAME|10001077|10001745|15239|10123673|GENDER|zc",
    "NAME|10002165|10000102|10151364|10151363|GENDER|ic",
    "NAME|10002165|10003668|10151364|10151363|GENDER|za",
    "NAME|10002165|10003668|10151364|10151363|GENDER|zc",
    "NAME|10002167|10003670|10151368|10151367|GENDER|cc",
"NAME|10002167|10003670|10151368|10151367|GENDER|zb"    };

    for (String s : Str){
        System.out.println(s);
        System.out.println(s.matches("^NAME\\|10002167\\|.*\\|.*\\|.*\\|*$"));
    }



   }
 } 

For above program I get all input values as matches, actually it should match only strings where first column = “NAME” and 2nd column is 10002167.

Update : Thanks to @Aviram Segal. After correcting regex it works in Java test program but not in HBase scan filter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:01:03+00:00Added an answer on June 16, 2026 at 8:01 am

    Your forgot to escape one | character so it is treated as an OR, also you can use [|] instead of \\|, personally I like that style better.

    Yours: ^NAME\\|.*\\|10000101|.*\\|.*\\|.*\\|.*$

    Fixed: ^NAME\\|.*\\|10000101\\|.*\\|.*\\|.*\\|.*$


    Yours: System.out.println(s.matches("^NAME\\|10002167|.*\\|.*\\|.*\\|*$"));

    Fixed: System.out.println(s.matches("^NAME\\|10002167\\|.*\\|.*\\|.*\\|*$"));

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with a regular expression. I'm working with tokens and I
I am having a problem with my regular expression: <a.*href=[\'](.*?)[\'].*>(.*?)</a> . It is, as
I need a regular expression to solve the following problem (links to similar problems
I have little problem in regular expressin creation. Expected input: blahblahblah, blahblahblah, 'blahblahblah', blahblahblah,
I'm using JavaScript to do some regular expression. Considering I'm working with well-formed source,
I am doing a string parsing problem in PHP. I want a regular expression
I have a little problem with my regular expression, that I use in PHP.
I've a regular expression problem, and I guess I'm missing a point in how
I started learning regular expression recently. I have a small problem statement now. I
I found a Question similar to my problem( Regular Expression For URL Query )

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.