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: 5495. 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)

Length: 0b, Line: 1, Cursor: 0

RegexOptions

IsMatch=true


#ValueIndexLengthGroupsCaptures
0101Skip Navigation Links.Skip Navigation Links.
10122Skip Navigation Links.Skip Navigation Links.
21252Skip Navigation Links.Skip Navigation Links.
312383Skip Navigation Links.Skip Navigation Links.
41234124Skip Navigation Links.Skip Navigation Links.
512345175Skip Navigation Links.Skip Navigation Links.
6123456789122311Skip Navigation Links.Skip Navigation Links.
71234567891233512Skip Navigation Links.Skip Navigation Links.
8-1482Skip Navigation Links.Skip Navigation Links.
9-12513Skip Navigation Links.Skip Navigation Links.
10-123554Skip Navigation Links.Skip Navigation Links.
11-1234605Skip Navigation Links.Skip Navigation Links.
12-12345666Skip Navigation Links.Skip Navigation Links.
130731Skip Navigation Links.Skip Navigation Links.
14100753Skip Navigation Links.Skip Navigation Links.
15-123456789127912Skip Navigation Links.Skip Navigation Links.
Count: 16, Time: 00:00:00.0156259

Share (without adding to database):

Source code

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)

Home     Match     Replace     Split     Help     Library     Contacts     netregex rss

Made by Koshevoy Dmitry [8Bytes],

© 2014-2024 Ukraine, Nikolaev.