Get envelopeID from a string using regex

Batty :

I have following strings :

"envelopeId": "fsadjhfkhdsgf", "ashgjkadsagagsalkjghsag": "gsajgks", "envelopeId": "fsadjhfkhdsgfgsd", "afshdj":"gas"

And I need to extract out all envelopeIds from this. I have tried different regex but nothing seems to work.

(?:"envelopeId": ")*(",)

(?:"envelopeId": ")*[\d\D](",)

What is wrong with the regex I am trying?

Wiktor Stribiżew :

You may use

"envelopeId":\s*"([^"]+)"

And extract matcher.group(1) values. See the regex demo.

Details

  • "envelopeId": - a literal string
  • \s* - 0+ whitespaces
  • " - a " char
  • ([^"]+) - Group 1: any 1+ chars other than "
  • " - a " char.

Java demo:

String s = "\"envelopeId\": \"fsadjhfkhdsgf\", \"ashgjkadsagagsalkjghsag\": \"gsajgks\", \"envelopeId\": \"fsadjhfkhdsgfgsd\", \"afshdj\":\"gas\"";
String key = "envelopeId";
Pattern pattern = Pattern.compile("\"" + Pattern.quote(key) + "\":\\s*\"([^\"]+)\"");
Matcher matcher = pattern.matcher(s);
while (matcher.find()){
    System.out.println(matcher.group(1)); 
}

Output:

fsadjhfkhdsgf
fsadjhfkhdsgfgsd

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

get word from string but not in html tags using python regex

分類Dev

Extracting numbers from string in R using regex

分類Dev

identify version from a string using php regex

分類Dev

Extract values from string using regex groups

分類Dev

Get the quantity from the description in Pyspark using regex

分類Dev

Using Regex to get string between lookbehind and lookahead with brackets and parenthesis in it

分類Dev

Get all alphabets in a string of words using regex (including spaces)

分類Dev

get second last component of a path from a string with js regex

分類Dev

How to get values of Year,Month and Day from String with help of Regex

分類Dev

Regex to get digits from a string when there is no separator between digits

分類Dev

javascript regex to get url from string containing script tag

分類Dev

Regex to get string between \" and \"

分類Dev

Removing int and float from the end of a string using Javascript regex

分類Dev

Regex to remove comments from SQL Query String using JavaScript

分類Dev

remove curly braces from string in python using regex

分類Dev

Creating regex to extract 4 digit number from string using java

分類Dev

bash/sed script to get output from a file using a regex

分類Dev

Get substring using regex

分類Dev

Regex: How can I always get 'abc' from the following set of strings using regex:

分類Dev

Get a specific string with Regex in Python

分類Dev

Highlighting a bloc of string using regex

分類Dev

showing repeating string using regex

分類Dev

Using Regex to detect if string exists

分類Dev

PowerShell split string using RegEx

分類Dev

How to get exact 8 digit from string using regular expression?

分類Dev

How get data from mySQL using string with params?

分類Dev

Regex - delete numbers from string

分類Dev

Regex to retrieve numbers from string

分類Dev

Extract data from string with regex

Related 関連記事

  1. 1

    get word from string but not in html tags using python regex

  2. 2

    Extracting numbers from string in R using regex

  3. 3

    identify version from a string using php regex

  4. 4

    Extract values from string using regex groups

  5. 5

    Get the quantity from the description in Pyspark using regex

  6. 6

    Using Regex to get string between lookbehind and lookahead with brackets and parenthesis in it

  7. 7

    Get all alphabets in a string of words using regex (including spaces)

  8. 8

    get second last component of a path from a string with js regex

  9. 9

    How to get values of Year,Month and Day from String with help of Regex

  10. 10

    Regex to get digits from a string when there is no separator between digits

  11. 11

    javascript regex to get url from string containing script tag

  12. 12

    Regex to get string between \" and \"

  13. 13

    Removing int and float from the end of a string using Javascript regex

  14. 14

    Regex to remove comments from SQL Query String using JavaScript

  15. 15

    remove curly braces from string in python using regex

  16. 16

    Creating regex to extract 4 digit number from string using java

  17. 17

    bash/sed script to get output from a file using a regex

  18. 18

    Get substring using regex

  19. 19

    Regex: How can I always get 'abc' from the following set of strings using regex:

  20. 20

    Get a specific string with Regex in Python

  21. 21

    Highlighting a bloc of string using regex

  22. 22

    showing repeating string using regex

  23. 23

    Using Regex to detect if string exists

  24. 24

    PowerShell split string using RegEx

  25. 25

    How to get exact 8 digit from string using regular expression?

  26. 26

    How get data from mySQL using string with params?

  27. 27

    Regex - delete numbers from string

  28. 28

    Regex to retrieve numbers from string

  29. 29

    Extract data from string with regex

ホットタグ

アーカイブ