Click here to Skip to main content
15,115,261 members
Home / Discussions / Regular Expressions
   

Regular Expressions

 
GeneralRe: Regex Expression to extract everything following a string and before a space Pin
Member 1457241529-Aug-19 9:00
MemberMember 1457241529-Aug-19 9:00 
GeneralRe: Regex Expression to extract everything following a string and before a space Pin
Member 1457241529-Aug-19 9:03
MemberMember 1457241529-Aug-19 9:03 
GeneralRe: Regex Expression to extract everything following a string and before a space Pin
Richard Deeming29-Aug-19 9:50
mveRichard Deeming29-Aug-19 9:50 
GeneralRe: Regex Expression to extract everything following a string and before a space Pin
Member 1457241529-Aug-19 10:12
MemberMember 1457241529-Aug-19 10:12 
GeneralRe: Regex Expression to extract everything following a string and before a space Pin
Richard Deeming29-Aug-19 10:53
mveRichard Deeming29-Aug-19 10:53 
GeneralRe: Regex Expression to extract everything following a string and before a space Pin
Member 1457241529-Aug-19 11:05
MemberMember 1457241529-Aug-19 11:05 
GeneralRe: Regex Expression to extract everything following a string and before a space Pin
phil.o29-Aug-19 20:29
mvephil.o29-Aug-19 20:29 
GeneralRe: Regex Expression to extract everything following a string and before a space Pin
Richard Deeming30-Aug-19 4:05
mveRichard Deeming30-Aug-19 4:05 
QuestionMatching separate regions Pin
Member 1450443318-Jun-19 5:10
MemberMember 1450443318-Jun-19 5:10 
AnswerRe: Matching separate regions Pin
OriginalGriff18-Jun-19 5:12
mveOriginalGriff18-Jun-19 5:12 
GeneralRe: Matching separate regions Pin
Member 1450443318-Jun-19 6:40
MemberMember 1450443318-Jun-19 6:40 
GeneralRe: Matching separate regions Pin
OriginalGriff18-Jun-19 6:46
mveOriginalGriff18-Jun-19 6:46 
QuestionCannot extract end of line data Pin
mo14927-Jan-19 4:44
Membermo14927-Jan-19 4:44 
AnswerRe: Cannot extract end of line data Pin
jsc4211-Apr-20 9:48
professionaljsc4211-Apr-20 9:48 
QuestionRegex code to check textfield is working until a 'enter' is given Pin
Member 1255403315-Mar-18 7:10
MemberMember 1255403315-Mar-18 7:10 
AnswerRe: Regex code to check textfield is working until a 'enter' is given Pin
Gerry Schmitz15-Mar-18 7:27
mveGerry Schmitz15-Mar-18 7:27 
QuestionRe: Regex code to check textfield is working until a 'enter' is given Pin
User 1013254615-Mar-18 7:42
MemberUser 1013254615-Mar-18 7:42 
AnswerRe: Regex code to check textfield is working until a 'enter' is given Pin
Member 1255403315-Mar-18 7:53
MemberMember 1255403315-Mar-18 7:53 
GeneralRe: Regex code to check textfield is working until a 'enter' is given Pin
User 1013254616-Mar-18 4:07
MemberUser 1013254616-Mar-18 4:07 
GeneralRe: Regex code to check textfield is working until a 'enter' is given Pin
Member 1255403316-Mar-18 5:51
MemberMember 1255403316-Mar-18 5:51 
Questionregular expression to find tax file numbers Pin
Copalol3-Dec-17 20:08
MemberCopalol3-Dec-17 20:08 
AnswerRe: regular expression to find tax file numbers Pin
Peter_in_27803-Dec-17 20:48
professionalPeter_in_27803-Dec-17 20:48 
GeneralRe: regular expression to find tax file numbers Pin
jschell5-Dec-17 13:06
Memberjschell5-Dec-17 13:06 
AnswerRe: regular expression to find tax file numbers Pin
George Jonsson5-Dec-17 0:25
professionalGeorge Jonsson5-Dec-17 0:25 
I agree with Peter_in_2780 that you should separate the matching of the number and the validation calculation.

Just create two methods, one where you check the format and the other to calculate and validate the check digit.

You didn't specify any variants of the text you want to match, so I just guessed what it could look like.

For the actual regular expression you could do like this:
Input: TFN '123456782'
Regex: ^TFN\s*(')?(?<number>\d{3}\s*\d{3}\s*\d{3})(')?\s*$

It will get these variants:
TFN '123456782'
TFN'123 456 782'
TFN123456782
TFN 123 456 782


Explanation:
^    Start of the string
$    End of the string
\s*  Consumes 0 or more white space characters. It will make sure you match TFN123 and TFN    123
(')? Optional quotation mark
(?<number> ...) Named group, makes it easier to extract the actual number


If necessary, you will have to remove the spaces in a second step.

Hope it helps.
GeneralRe: regular expression to find tax file numbers Pin
Copalol5-Dec-17 14:05
MemberCopalol5-Dec-17 14:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.