.NET Regex
Match
Replace
Split
Library
Help
Contacts
Sign In
Sign In
Login (or email):
Password:
registration
|
forgot password?
System.Text.
RegularExpressions
.NET Regex
.Match
x
Did you like it?
Well, then please consider making a
donation
:)
If else condition on minus sign
If numbers are negative then length of numbers is 11 otherwise 12
Tags:
#
condition
, #
if-else-numbers
.
Views:
5591.
mahajan344
, 4/14/2016
Link 1:
http://www.systemtextregularexpressions.com/m24/if-else-condition-on-minus-sign
Link 2:
http://www.systemtextregularexpressions.com/m24
(short)
new
open
upload text file
get html from url
add to library
share
Start
Copy
1 01 12 123 1234 12345 12345678912 123456789123 -1 -12 -123 -1234 -12345 0 100 -12345678912 -123456789123
Length: 0b, Line: 1, Cursor: 0
RegexOptions
None
Compiled
CultureInvariant
ECMAScript
ExplicitCapture
IgnoreCase
IgnorePatternWhite…
Multiline
RightToLeft
Singleline
Upload text file
Codepage
ASMO-708
big5
cp1025
cp866
cp875
csISO2022JP
DOS-720
DOS-862
EUC-CN
euc-jp
EUC-JP
euc-kr
GB18030
gb2312
hz-gb-2312
IBM00858
IBM00924
IBM01047
IBM01140
IBM01141
IBM01142
IBM01143
IBM01144
IBM01145
IBM01146
IBM01147
IBM01148
IBM01149
IBM037
IBM1026
IBM273
IBM277
IBM278
IBM280
IBM284
IBM285
IBM290
IBM297
IBM420
IBM423
IBM424
IBM437
IBM500
ibm737
ibm775
ibm850
ibm852
IBM855
ibm857
IBM860
ibm861
IBM863
IBM864
IBM865
ibm869
IBM870
IBM871
IBM880
IBM905
IBM-Thai
iso-2022-jp
iso-2022-jp
iso-2022-kr
iso-8859-1
iso-8859-13
iso-8859-15
iso-8859-2
iso-8859-3
iso-8859-4
iso-8859-5
iso-8859-6
iso-8859-7
iso-8859-8
iso-8859-8-i
iso-8859-9
Johab
koi8-r
koi8-u
ks_c_5601-1987
macintosh
shift_jis
us-ascii
utf-16
utf-16BE
utf-32
utf-32BE
utf-7
utf-8
windows-1250
windows-1251
Windows-1252
windows-1253
windows-1254
windows-1255
windows-1256
windows-1257
windows-1258
windows-874
x-Chinese-CNS
x-Chinese-Eten
x-cp20001
x-cp20003
x-cp20004
x-cp20005
x-cp20261
x-cp20269
x-cp20936
x-cp20949
x-cp50227
x-EBCDIC-KoreanExtended
x-Europa
x-IA5
x-IA5-German
x-IA5-Norwegian
x-IA5-Swedish
x-iscii-as
x-iscii-be
x-iscii-de
x-iscii-gu
x-iscii-ka
x-iscii-ma
x-iscii-or
x-iscii-pa
x-iscii-ta
x-iscii-te
x-mac-arabic
x-mac-ce
x-mac-chinesesimp
x-mac-chinesetrad
x-mac-croatian
x-mac-cyrillic
x-mac-greek
x-mac-hebrew
x-mac-icelandic
x-mac-japanese
x-mac-korean
x-mac-romanian
x-mac-thai
x-mac-turkish
x-mac-ukrainian
Get content from URL
URL:
Codepage
ASMO-708
big5
cp1025
cp866
cp875
csISO2022JP
DOS-720
DOS-862
EUC-CN
euc-jp
EUC-JP
euc-kr
GB18030
gb2312
hz-gb-2312
IBM00858
IBM00924
IBM01047
IBM01140
IBM01141
IBM01142
IBM01143
IBM01144
IBM01145
IBM01146
IBM01147
IBM01148
IBM01149
IBM037
IBM1026
IBM273
IBM277
IBM278
IBM280
IBM284
IBM285
IBM290
IBM297
IBM420
IBM423
IBM424
IBM437
IBM500
ibm737
ibm775
ibm850
ibm852
IBM855
ibm857
IBM860
ibm861
IBM863
IBM864
IBM865
ibm869
IBM870
IBM871
IBM880
IBM905
IBM-Thai
iso-2022-jp
iso-2022-jp
iso-2022-kr
iso-8859-1
iso-8859-13
iso-8859-15
iso-8859-2
iso-8859-3
iso-8859-4
iso-8859-5
iso-8859-6
iso-8859-7
iso-8859-8
iso-8859-8-i
iso-8859-9
Johab
koi8-r
koi8-u
ks_c_5601-1987
macintosh
shift_jis
us-ascii
utf-16
utf-16BE
utf-32
utf-32BE
utf-7
utf-8
windows-1250
windows-1251
Windows-1252
windows-1253
windows-1254
windows-1255
windows-1256
windows-1257
windows-1258
windows-874
x-Chinese-CNS
x-Chinese-Eten
x-cp20001
x-cp20003
x-cp20004
x-cp20005
x-cp20261
x-cp20269
x-cp20936
x-cp20949
x-cp50227
x-EBCDIC-KoreanExtended
x-Europa
x-IA5
x-IA5-German
x-IA5-Norwegian
x-IA5-Swedish
x-iscii-as
x-iscii-be
x-iscii-de
x-iscii-gu
x-iscii-ka
x-iscii-ma
x-iscii-or
x-iscii-pa
x-iscii-ta
x-iscii-te
x-mac-arabic
x-mac-ce
x-mac-chinesesimp
x-mac-chinesetrad
x-mac-croatian
x-mac-cyrillic
x-mac-greek
x-mac-hebrew
x-mac-icelandic
x-mac-japanese
x-mac-korean
x-mac-romanian
x-mac-thai
x-mac-turkish
x-mac-ukrainian
Referer
Useragent
Auto redirect
Result
Share Regex
Name (minlength: 15)
*
Keywords (min: 3)
*
Category
*
Date & Time
Digits, Numbers
E-Mail, Url
Other
Phone, ZipCode
Strings, Text
Web, Html
Allow comments
Description
IsMatch=true
#
Value
Index
Length
Groups
Captures
0
1
0
1
Groups [1]
[0]
1
Name:
0
Index: 0, length: 1, success.
Captures [1]
[0]
1
Index: 0, length: 1
Captures [1]
[0]
1
Index: 0, length: 1
1
01
2
2
Groups [1]
[0]
01
Name:
0
Index: 2, length: 2, success.
Captures [1]
[0]
01
Index: 2, length: 2
Captures [1]
[0]
01
Index: 2, length: 2
2
12
5
2
Groups [1]
[0]
12
Name:
0
Index: 5, length: 2, success.
Captures [1]
[0]
12
Index: 5, length: 2
Captures [1]
[0]
12
Index: 5, length: 2
3
123
8
3
Groups [1]
[0]
123
Name:
0
Index: 8, length: 3, success.
Captures [1]
[0]
123
Index: 8, length: 3
Captures [1]
[0]
123
Index: 8, length: 3
4
1234
12
4
Groups [1]
[0]
1234
Name:
0
Index: 12, length: 4, success.
Captures [1]
[0]
1234
Index: 12, length: 4
Captures [1]
[0]
1234
Index: 12, length: 4
5
12345
17
5
Groups [1]
[0]
12345
Name:
0
Index: 17, length: 5, success.
Captures [1]
[0]
12345
Index: 17, length: 5
Captures [1]
[0]
12345
Index: 17, length: 5
6
12345678912
23
11
Groups [1]
[0]
12345678912
Name:
0
Index: 23, length: 11, success.
Captures [1]
[0]
12345678912
Index: 23, length: 11
Captures [1]
[0]
12345678912
Index: 23, length: 11
7
123456789123
35
12
Groups [1]
[0]
123456789123
Name:
0
Index: 35, length: 12, success.
Captures [1]
[0]
123456789123
Index: 35, length: 12
Captures [1]
[0]
123456789123
Index: 35, length: 12
8
-1
48
2
Groups [1]
[0]
-1
Name:
0
Index: 48, length: 2, success.
Captures [1]
[0]
-1
Index: 48, length: 2
Captures [1]
[0]
-1
Index: 48, length: 2
9
-12
51
3
Groups [1]
[0]
-12
Name:
0
Index: 51, length: 3, success.
Captures [1]
[0]
-12
Index: 51, length: 3
Captures [1]
[0]
-12
Index: 51, length: 3
10
-123
55
4
Groups [1]
[0]
-123
Name:
0
Index: 55, length: 4, success.
Captures [1]
[0]
-123
Index: 55, length: 4
Captures [1]
[0]
-123
Index: 55, length: 4
11
-1234
60
5
Groups [1]
[0]
-1234
Name:
0
Index: 60, length: 5, success.
Captures [1]
[0]
-1234
Index: 60, length: 5
Captures [1]
[0]
-1234
Index: 60, length: 5
12
-12345
66
6
Groups [1]
[0]
-12345
Name:
0
Index: 66, length: 6, success.
Captures [1]
[0]
-12345
Index: 66, length: 6
Captures [1]
[0]
-12345
Index: 66, length: 6
13
0
73
1
Groups [1]
[0]
0
Name:
0
Index: 73, length: 1, success.
Captures [1]
[0]
0
Index: 73, length: 1
Captures [1]
[0]
0
Index: 73, length: 1
14
100
75
3
Groups [1]
[0]
100
Name:
0
Index: 75, length: 3, success.
Captures [1]
[0]
100
Index: 75, length: 3
Captures [1]
[0]
100
Index: 75, length: 3
15
-12345678912
79
12
Groups [1]
[0]
-12345678912
Name:
0
Index: 79, length: 12, success.
Captures [1]
[0]
-12345678912
Index: 79, length: 12
Captures [1]
[0]
-12345678912
Index: 79, length: 12
Count: 16, Time: 00:00:00
Share (without adding to database):
Copy
Source code
C#
VB.NET
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
//.NET Regex.Match Online Tester: www.systemtextregularexpressions.com
//Namespace
using
System.Text.RegularExpressions;
//Regex Pattern
string
pattern =
@"^(?(-)^-\d{0,11}$|^\d{0,12}$)"
;
//Regex example #1
Regex
r = new
Regex
(
@"^(?(-)^-\d{0,11}$|^\d{0,12}$)"
,
RegexOptions
.Multiline);
Match
m1 = r.
Match
(
"input text"
);
MatchCollection
mc1 = r.
Matches
(
"input text"
);
//Regex example #2
Match
m2 =
Regex
.
Match
(
"input text", @"^(?(-)^-\d{0,11}$|^\d{0,12}$)"
,
RegexOptions
.Multiline);
MatchCollection
mc2 =
Regex
.
Matches
(
"input text", @"^(?(-)^-\d{0,11}$|^\d{0,12}$)"
,
RegexOptions
.Multiline);
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
'.NET Regex.Match Online Tester: www.systemtextregularexpressions.com
'Namespace
Imports
System.Text.RegularExpressions
'Regex Pattern
Dim
pattern
As
String
=
"^(?(-)^-\d{0,11}$|^\d{0,12}$)"
'Regex example #1
Dim
r
As
Regex
=
New
Regex
(
"^(?(-)^-\d{0,11}$|^\d{0,12}$)"
,
RegexOptions
.Multiline)
Dim
m1
As
Match
= r.
Match
(
"input text"
)
Dim
mc
As
MatchCollection
= r.
Matches
(
"input text"
)
'Regex example #2
Dim
m2
As
Match
=
Regex
.
Match
(
"input text", "^(?(-)^-\d{0,11}$|^\d{0,12}$)"
,
RegexOptions
.Multiline)
Dim
mc2
As
MatchCollection
=
Regex
.
Matches
(
"input text", "^(?(-)^-\d{0,11}$|^\d{0,12}$)"
,
RegexOptions
.Multiline)