# Regular expression to build 2D array-java

**URL:** https://forum.kirupa.com/t/regular-expression-to-build-2d-array-java/646874
**Category:** programming
**Created:** [March 27, 2021, 11:17pm UTC](https://forum.kirupa.com/t/regular-expression-to-build-2d-array-java/646874 "2021-03-27T23:17:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Umair\_Ashraf](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/umair_ashraf/32/11705_2.png) [@Umair\_Ashraf](https://forum.kirupa.com/u/Umair_Ashraf)
#### Post date: [March 27, 2021, 11:17pm UTC](https://forum.kirupa.com/t/regular-expression-to-build-2d-array-java/646874/1 "2021-03-27T23:17:27Z")

</div>

I am struggling to form the regex expression from the below String Array `notes`.

I have tried to use few things below but I am not getting what I am expecting, like from `notes[0]` I am only expecting `10.0` and `higher`, Whereas it is printing all the String till the end `higher than in-store`, I though `\b...\b` will pick up the exact match but its not working here.

Any Pointers on this please.

```auto
    notes = ["10.0% higher than in-store", 
             "5.0% lower than in-store", 
             "Same as in-store"]

    String[][] twoDarray= new String[notes.length][2];

    for (int index=0; index<notes.length;index++){ 
        twoDarray[index]= notes[index].split("(\\%) | /\bhigher\b/ | /\blower\b/ | /\bsame\b/ | /\bas\b/");
    }

    System.out.println( twoDarray [0][0]); //10.0 (correct)
    System.out.println( twoDarray [0][1]); //higher than in-store (expected: higher)
    System.out.println( twoDarray [1][0]); //5.0 (correct)
    System.out.println( twoDarray [1][1]); //lower than in-store (expected: lower)
    System.out.println( twoDarray [2][0]); //Same as in-store (expected: Same)
    System.out.println( twoDarray [2][1]); // no output? (expected: as)

```
