[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

How to improve this pattern for multidimentional arrays

Hello,
I am using the folloiwng java pattern to trap the user input for a single dimentional array.
inString.matches("[\\w\\-]+\\[\\d+\\]");

where inString is the input string. This works great. Now I want to improve this to any multi dimensional array. For example

arrayName[2]
arrayName[[3][1]
arrayName[5][1][4]
arrayNAme[1][2][4][2]  etc. (All Java style multidimensional arrays)

How do I do this to the pattern?
0
prain
Asked:
prain
  • 2
1 Solution
 
CEHJCommented:
Try

inString.matches("[\\w\\-]+(?:\\[\\d+\\])+");

Open in new window

0
 
prainAuthor Commented:
Great! Thank You Very Much!!!!!!!!!!!!!
0
 
CEHJCommented:
:)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now