-3

I have the following string "*&abc=123&**&defg=hh&*" and so on the pattern start and end is && and I would like to have the following when I do regex.matches or regex.split

first match = &abc=123& 2 match = &defg=hh&

appreciate any help

  • the pattern start and finish per pattern *&&* – user1293971 Jun 01 '16 at 20:08
  • Please try to use proper formatting. As it is, it's a little difficult to know exactly what you mean. There's also no instance of `&&` anywhere in that input string. – p.s.w.g Jun 01 '16 at 20:10

1 Answers1

1
&[0-9a-zA-Z]+=[0-9a-zA-Z]+&

You may need to change the [0-9a-zA-Z] depending on what characters you want to allow.

& matches the characters & literally
[0-9a-zA-Z]+ match a single character present in the list below
    Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
    0-9 a single character in the range between 0 and 9
    a-z a single character in the range between a and z (case sensitive)
    A-Z a single character in the range between A and Z (case sensitive)
= matches the character = literally
[0-9a-zA-Z]+ match a single character present in the list below
    Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
    0-9 a single character in the range between 0 and 9
    a-z a single character in the range between a and z (case sensitive)
    A-Z a single character in the range between A and Z (case sensitive)
& matches the characters & literally