Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 215 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JScript Regex - extract 10-digit VAT number with seperators procedeed by a substring

#1
I need to extract VAT number that consists of 10 digits seperated by a dash, space or not seperated and procedeed by substring 'VAT'. VAT number never starts start with zero and is always followed by a space.

reg = new RegExp('[\d -]{10}\\s','ig');
str = ('sdfgzdfvzdfv/9/2020 VAT Invoice 16-09-2020 Citsxc zzzzw34 224- Iscvcge date 16.09.2020 VAT Terms 34 of payment: 123-456-78-90 *')
expected result: '123-456-78-90'

Thank you.
Reply

#2
You may use
```js
var rx = RegExp('VAT.*?([1-9](?:[\\s-]?\\d){9})(?!\\S)','i');
```
See the [regex demo][1]. Details:

- `VAT` - a `VAT` substring
- `.*?` - any 0+ chars other than line break chars, as few as possible
- `([1-9](?:[\s-]?\d){9})` - Group 1:
- `[1-9]` - a non-zero digit
- `(?:[\s-]?\d){9}` - 9 occurrences of a whitespace or hyphen and then a digit
- `(?!\S)` - a right-hand whitespace boundary.

JScript code demo:
```js
var rx = RegExp('VAT.*?([1-9](?:[\s-]?\\d){9})(?!\\S)','i');
var string=('sdfgzdfvzdfv/9/2020 VAT Invoice 16-09-2020 Citsxc zzzzw34 224- Iscvcge date 16.09.2020 VAT Terms 34 of payment123-456-78-90 ');
var m = string.match(rx);
if (m) {
WScript.Echo(m[1]);
} else {
WScript.Echo("No match!");
}
```
Output: `123-456-78-90`.

[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through