RegEX - Find Magnetic Card String for Track 1 and Track 2 substringsHow to check if a string contains a substring in BashHow to check whether a string contains a substring in JavaScript?In Java, how do I check if a string contains a substring (ignoring case)?Does Python have a string 'contains' substring method?How do I check if string contains substring?Where can I find magnetic strip (track) test data?How to getting started with magnetic stripe cards?Reading and writing magnetic card reader input with PythonHow to read a magnetic card in androidMSR605 Magnetic Card Reader unable to read cards without special software
How to align and center standalone amsmath equations?
Can the Supreme Court overturn an impeachment?
Is camera lens focus an exact point or a range?
Proving a function is onto where f(x)=|x|.
Open a doc from terminal, but not by its name
THT: What is a squared annular “ring”?
Bob has never been a M before
Why is Arduino resetting while driving motors?
Do the concepts of IP address and network interface not belong to the same layer?
Drawing a topological "handle" with Tikz
Reply 'no position' while the job posting is still there
Varistor? Purpose and principle
Why did the EU agree to delay the Brexit deadline?
Journal losing indexing services
Two-sided logarithm inequality
Why did the HMS Bounty go back to a time when whales are already rare?
Divine apple island
Flux received by a negative charge
What major Native American tribes were around Santa Fe during the late 1850s?
What does this horizontal bar at the first measure mean?
Freedom of speech and where it applies
Database accidentally deleted with a bash script
A Permanent Norse Presence in America
Could solar power be utilized and substitute coal in the 19th Century
RegEX - Find Magnetic Card String for Track 1 and Track 2 substrings
How to check if a string contains a substring in BashHow to check whether a string contains a substring in JavaScript?In Java, how do I check if a string contains a substring (ignoring case)?Does Python have a string 'contains' substring method?How do I check if string contains substring?Where can I find magnetic strip (track) test data?How to getting started with magnetic stripe cards?Reading and writing magnetic card reader input with PythonHow to read a magnetic card in androidMSR605 Magnetic Card Reader unable to read cards without special software
A Card reader is simply a keyboard input that once a Card is swiped, a string is displayed in any focused text field.
I would like to split the following:
Track 1: which is delimited by a % and a ?
Track 2: which is delimited by a ; and a ?
However not all Cards have both Tracks, some have only the first, and some have only the second.
I'd like to find a RegEx that parses out Track 1 and Track 2 if either exist.
Here are sample Cards swipes which generates these Strings:
%12345?;54321? (has both Track 1 & Track 2)
%1234678? (has only Track 1)
;98765? (has only Track 2)
%93857563932746584?;38475? (has both Track 1 & Track 2)
This is the example I'm building off of:
%([0-9]+)?) // for first Track
;([0-9]+)?) // for second Track
regex actionscript-3 substring magnetic-cards
add a comment |
A Card reader is simply a keyboard input that once a Card is swiped, a string is displayed in any focused text field.
I would like to split the following:
Track 1: which is delimited by a % and a ?
Track 2: which is delimited by a ; and a ?
However not all Cards have both Tracks, some have only the first, and some have only the second.
I'd like to find a RegEx that parses out Track 1 and Track 2 if either exist.
Here are sample Cards swipes which generates these Strings:
%12345?;54321? (has both Track 1 & Track 2)
%1234678? (has only Track 1)
;98765? (has only Track 2)
%93857563932746584?;38475? (has both Track 1 & Track 2)
This is the example I'm building off of:
%([0-9]+)?) // for first Track
;([0-9]+)?) // for second Track
regex actionscript-3 substring magnetic-cards
While you wait to find the RegEx... For such simple strings, why not just usesubstr
and/orsubstring
together withfirstIndexOf(x)
orlastIndexOf(x)
where thex
could be the%
or?
or;
... Also if your "tracks" are numerical why not extract by splitting at & then also removing special characters (leaves tracks)?
– VC.One
Mar 21 at 14:45
PS: I think you got down-voted because your programming question has neither RegEx nor AS3 codes. Show your best try with this regEx and maybe someone can fix it.
– VC.One
Mar 21 at 14:48
I did use finding by Index the delimeters, and substring-ing the indexes, however it did not work for all my use cases.
– Yozef
Mar 21 at 20:52
add a comment |
A Card reader is simply a keyboard input that once a Card is swiped, a string is displayed in any focused text field.
I would like to split the following:
Track 1: which is delimited by a % and a ?
Track 2: which is delimited by a ; and a ?
However not all Cards have both Tracks, some have only the first, and some have only the second.
I'd like to find a RegEx that parses out Track 1 and Track 2 if either exist.
Here are sample Cards swipes which generates these Strings:
%12345?;54321? (has both Track 1 & Track 2)
%1234678? (has only Track 1)
;98765? (has only Track 2)
%93857563932746584?;38475? (has both Track 1 & Track 2)
This is the example I'm building off of:
%([0-9]+)?) // for first Track
;([0-9]+)?) // for second Track
regex actionscript-3 substring magnetic-cards
A Card reader is simply a keyboard input that once a Card is swiped, a string is displayed in any focused text field.
I would like to split the following:
Track 1: which is delimited by a % and a ?
Track 2: which is delimited by a ; and a ?
However not all Cards have both Tracks, some have only the first, and some have only the second.
I'd like to find a RegEx that parses out Track 1 and Track 2 if either exist.
Here are sample Cards swipes which generates these Strings:
%12345?;54321? (has both Track 1 & Track 2)
%1234678? (has only Track 1)
;98765? (has only Track 2)
%93857563932746584?;38475? (has both Track 1 & Track 2)
This is the example I'm building off of:
%([0-9]+)?) // for first Track
;([0-9]+)?) // for second Track
regex actionscript-3 substring magnetic-cards
regex actionscript-3 substring magnetic-cards
edited 2 days ago
Yozef
asked Mar 21 at 13:49
YozefYozef
7971027
7971027
While you wait to find the RegEx... For such simple strings, why not just usesubstr
and/orsubstring
together withfirstIndexOf(x)
orlastIndexOf(x)
where thex
could be the%
or?
or;
... Also if your "tracks" are numerical why not extract by splitting at & then also removing special characters (leaves tracks)?
– VC.One
Mar 21 at 14:45
PS: I think you got down-voted because your programming question has neither RegEx nor AS3 codes. Show your best try with this regEx and maybe someone can fix it.
– VC.One
Mar 21 at 14:48
I did use finding by Index the delimeters, and substring-ing the indexes, however it did not work for all my use cases.
– Yozef
Mar 21 at 20:52
add a comment |
While you wait to find the RegEx... For such simple strings, why not just usesubstr
and/orsubstring
together withfirstIndexOf(x)
orlastIndexOf(x)
where thex
could be the%
or?
or;
... Also if your "tracks" are numerical why not extract by splitting at & then also removing special characters (leaves tracks)?
– VC.One
Mar 21 at 14:45
PS: I think you got down-voted because your programming question has neither RegEx nor AS3 codes. Show your best try with this regEx and maybe someone can fix it.
– VC.One
Mar 21 at 14:48
I did use finding by Index the delimeters, and substring-ing the indexes, however it did not work for all my use cases.
– Yozef
Mar 21 at 20:52
While you wait to find the RegEx... For such simple strings, why not just use
substr
and/or substring
together with firstIndexOf(x)
or lastIndexOf(x)
where the x
could be the %
or ?
or ;
... Also if your "tracks" are numerical why not extract by splitting at & then also removing special characters (leaves tracks)?– VC.One
Mar 21 at 14:45
While you wait to find the RegEx... For such simple strings, why not just use
substr
and/or substring
together with firstIndexOf(x)
or lastIndexOf(x)
where the x
could be the %
or ?
or ;
... Also if your "tracks" are numerical why not extract by splitting at & then also removing special characters (leaves tracks)?– VC.One
Mar 21 at 14:45
PS: I think you got down-voted because your programming question has neither RegEx nor AS3 codes. Show your best try with this regEx and maybe someone can fix it.
– VC.One
Mar 21 at 14:48
PS: I think you got down-voted because your programming question has neither RegEx nor AS3 codes. Show your best try with this regEx and maybe someone can fix it.
– VC.One
Mar 21 at 14:48
I did use finding by Index the delimeters, and substring-ing the indexes, however it did not work for all my use cases.
– Yozef
Mar 21 at 20:52
I did use finding by Index the delimeters, and substring-ing the indexes, however it did not work for all my use cases.
– Yozef
Mar 21 at 20:52
add a comment |
1 Answer
1
active
oldest
votes
This regex will match your track groupings:
/(?:%([0-9]+)?)?(?:;([0-9]+)?)?/g
(?: // non-capturing group
% // match the % character
( // capturing group for the first number
[0-9] // match digits; could also use d
+ // match 1 or more digits
) // close the group
? // match the ? character
)
? // match 0 or 1 of the non-capturing group
(?:
; // match the ; character
[0-9]
+
)
?
)
?
BTW, I used regexr to figure out the regex patterns here (free site, no affiliation).
@Yozef On the Replace tab, try this expression: << $1 - $2 >>
– Brian
Mar 21 at 21:13
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281952%2fregex-find-magnetic-card-string-for-track-1-and-track-2-substrings%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This regex will match your track groupings:
/(?:%([0-9]+)?)?(?:;([0-9]+)?)?/g
(?: // non-capturing group
% // match the % character
( // capturing group for the first number
[0-9] // match digits; could also use d
+ // match 1 or more digits
) // close the group
? // match the ? character
)
? // match 0 or 1 of the non-capturing group
(?:
; // match the ; character
[0-9]
+
)
?
)
?
BTW, I used regexr to figure out the regex patterns here (free site, no affiliation).
@Yozef On the Replace tab, try this expression: << $1 - $2 >>
– Brian
Mar 21 at 21:13
add a comment |
This regex will match your track groupings:
/(?:%([0-9]+)?)?(?:;([0-9]+)?)?/g
(?: // non-capturing group
% // match the % character
( // capturing group for the first number
[0-9] // match digits; could also use d
+ // match 1 or more digits
) // close the group
? // match the ? character
)
? // match 0 or 1 of the non-capturing group
(?:
; // match the ; character
[0-9]
+
)
?
)
?
BTW, I used regexr to figure out the regex patterns here (free site, no affiliation).
@Yozef On the Replace tab, try this expression: << $1 - $2 >>
– Brian
Mar 21 at 21:13
add a comment |
This regex will match your track groupings:
/(?:%([0-9]+)?)?(?:;([0-9]+)?)?/g
(?: // non-capturing group
% // match the % character
( // capturing group for the first number
[0-9] // match digits; could also use d
+ // match 1 or more digits
) // close the group
? // match the ? character
)
? // match 0 or 1 of the non-capturing group
(?:
; // match the ; character
[0-9]
+
)
?
)
?
BTW, I used regexr to figure out the regex patterns here (free site, no affiliation).
This regex will match your track groupings:
/(?:%([0-9]+)?)?(?:;([0-9]+)?)?/g
(?: // non-capturing group
% // match the % character
( // capturing group for the first number
[0-9] // match digits; could also use d
+ // match 1 or more digits
) // close the group
? // match the ? character
)
? // match 0 or 1 of the non-capturing group
(?:
; // match the ; character
[0-9]
+
)
?
)
?
BTW, I used regexr to figure out the regex patterns here (free site, no affiliation).
answered Mar 21 at 15:56
BrianBrian
3,43731535
3,43731535
@Yozef On the Replace tab, try this expression: << $1 - $2 >>
– Brian
Mar 21 at 21:13
add a comment |
@Yozef On the Replace tab, try this expression: << $1 - $2 >>
– Brian
Mar 21 at 21:13
@Yozef On the Replace tab, try this expression: << $1 - $2 >>
– Brian
Mar 21 at 21:13
@Yozef On the Replace tab, try this expression: << $1 - $2 >>
– Brian
Mar 21 at 21:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281952%2fregex-find-magnetic-card-string-for-track-1-and-track-2-substrings%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
While you wait to find the RegEx... For such simple strings, why not just use
substr
and/orsubstring
together withfirstIndexOf(x)
orlastIndexOf(x)
where thex
could be the%
or?
or;
... Also if your "tracks" are numerical why not extract by splitting at & then also removing special characters (leaves tracks)?– VC.One
Mar 21 at 14:45
PS: I think you got down-voted because your programming question has neither RegEx nor AS3 codes. Show your best try with this regEx and maybe someone can fix it.
– VC.One
Mar 21 at 14:48
I did use finding by Index the delimeters, and substring-ing the indexes, however it did not work for all my use cases.
– Yozef
Mar 21 at 20:52