-3

I am looking for regex pattern to extract the two words from a given text. I am looking for regex for applying in config file which would substitute in java code

For example - I have a long string - pabc_extracted_data_US_NETFLI_2020-11-26-17-02-03.csv.gz I want to extract whatever string coming after pabc_extracted_data_ (here US) and also looking for another regex for whatever string coming after pabc_extracted_data_US_ (here NETFLI)..

so my expected output for two regex would be US & NETFLI. Please help me as I'm new to this regex world

BigD
  • 685
  • 9
  • 29
  • You should try to format your message better. It could also help by telling in what language you are developing. Because the regex could differ. – Vivendi Dec 02 '20 at 12:48
  • A little extra detail would be useful. Do you know that these "strings" will be only letters and not numbers? Will they be all caps? – Hank Schultz Dec 02 '20 at 12:48

1 Answers1

-1

edited: first regex will be something like:

pabc_extracted_data_([^_]+)_

second will be something like:

pabc_extracted_data_[^_]+_([^_]+)

this seems to work: enter image description here

enter image description here

soqls
  • 26
  • 5
  • I am looking for two regex.. one for US other for NETFLI – BigD Dec 02 '20 at 12:50
  • @BigD, what language are you working in? Regex may not be the easiest solution. For example, if you're working in JavaScript, you could just split in the `'_'` character and take the elements of the array at certain positions. Also, without specifying the language, we can't help you _extract_ the strings. – Hank Schultz Dec 02 '20 at 12:53
  • I am looking for java code.. it should work if its works in regex101.com – BigD Dec 02 '20 at 12:54