I have a string
"Máy Tính Acer[Asprise 4741 | 058941144] - 302";
"Máy Tính Acer[Asprise 4741 | 058941145] - 302";
Now I want to use Regex to get 2 string result:
058941144
058941145
If you can use look-ahead and look-behind assertions, you can use this regex to match between | and ]:
(?<=\|\s)[0-9]+(?=])
In C#, you can use this code:
String input = "Máy Tính Acer[Asprise 4741 | 058941144] - 302";
String pattern = @"(?<=\|\s)[0-9]+(?=])";
var match = Regex.Match(input, pattern).ToString();
If you want to match bases on the whole string you put in your question, you can use a longer regex that works in basically the same way as the one above:
String pattern = @"(?<=Máy Tính Acer\[Asprise\s4741\s\|\s)[0-9]+(?=]\s-\s302)";
For a more generic pattern that will match any charaters, use
String pattern = @"(?<=\|).+(?=])";
\d{9}if the number is always 9 digits and the only 9 digit number.