What would be the Regex expression to get the first letter after a group of character and some integers?Regex for numbers onlyConverting user input string to regular expressionRegular expression to extract text between square bracketsRegular Expression: Any character that is NOT a letter or numberIs there a RegExp.escape function in Javascript?How to extract a substring using regexGreedy vs. Reluctant vs. Possessive QuantifiersReplace only some groups with Regexd is less efficient than [0-9]How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops
A life of PhD: is it feasible?
Is there a better way to do partial sums of array items in JavaScript?
Problem with pronounciation
What does the homotopy coherent nerve do to spaces of enriched functors?
Realistic, logical way for men with medieval-era weaponry to compete with much larger and physically stronger foes
Makefile for a simple Debian Repo
How much web presence should I have?
How to make a composition of functions prettier?
Why does there seem to be an extreme lack of public trashcans in Taiwan?
Was planting UN flag on Moon ever discussed?
Are the guests in Westworld forbidden to tell the hosts that they are robots?
Why are ambiguous grammars bad?
Why would a home insurer offer a discount based on credit score?
What's the best way to quit a job mostly because of money?
In The Incredibles 2, why does Screenslaver's name use a pun on something that doesn't exist in the 1950s pastiche?
Parsing text written the millitext font
What is the STRONGEST end-of-line knot to use if you want to use a steel-thimble at the end, so that you've got a steel-eyelet at the end of the line?
What does this line mean in Zelazny's "The Courts of Chaos"?
How many sets of dice do I need for D&D?
How to generate list of *all* available commands and functions?
How do I avoid typing "git" at the begining of every Git command?
How can you estimate a spike story?
What is the proper event in Extended Events to track stored procedure executions?
Professor Roman loves to teach unorthodox Chemistry
What would be the Regex expression to get the first letter after a group of character and some integers?
Regex for numbers onlyConverting user input string to regular expressionRegular expression to extract text between square bracketsRegular Expression: Any character that is NOT a letter or numberIs there a RegExp.escape function in Javascript?How to extract a substring using regexGreedy vs. Reluctant vs. Possessive QuantifiersReplace only some groups with Regexd is less efficient than [0-9]How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a string that the following structure:
ABCD123456EFGHIJ78 but sometimes it's missing a number or a character like:
ABC123456EFGHIJ78 or
ABCD123456E or
ABCD12345EFGHIJ78
etc.
That's why I need regular expressions.
What I want to extract is the first letter of the third group, in this case 'E'.
I have the following regex:
(D+)+(d+)+(D1)3
but I don't get the letter E.
regex
add a comment |
I have a string that the following structure:
ABCD123456EFGHIJ78 but sometimes it's missing a number or a character like:
ABC123456EFGHIJ78 or
ABCD123456E or
ABCD12345EFGHIJ78
etc.
That's why I need regular expressions.
What I want to extract is the first letter of the third group, in this case 'E'.
I have the following regex:
(D+)+(d+)+(D1)3
but I don't get the letter E.
regex
2
See regex101.com/r/5GA6YQ/1
– Wiktor Stribiżew
Mar 22 at 18:27
add a comment |
I have a string that the following structure:
ABCD123456EFGHIJ78 but sometimes it's missing a number or a character like:
ABC123456EFGHIJ78 or
ABCD123456E or
ABCD12345EFGHIJ78
etc.
That's why I need regular expressions.
What I want to extract is the first letter of the third group, in this case 'E'.
I have the following regex:
(D+)+(d+)+(D1)3
but I don't get the letter E.
regex
I have a string that the following structure:
ABCD123456EFGHIJ78 but sometimes it's missing a number or a character like:
ABC123456EFGHIJ78 or
ABCD123456E or
ABCD12345EFGHIJ78
etc.
That's why I need regular expressions.
What I want to extract is the first letter of the third group, in this case 'E'.
I have the following regex:
(D+)+(d+)+(D1)3
but I don't get the letter E.
regex
regex
asked Mar 22 at 18:25
esgesg
255
255
2
See regex101.com/r/5GA6YQ/1
– Wiktor Stribiżew
Mar 22 at 18:27
add a comment |
2
See regex101.com/r/5GA6YQ/1
– Wiktor Stribiżew
Mar 22 at 18:27
2
2
See regex101.com/r/5GA6YQ/1
– Wiktor Stribiżew
Mar 22 at 18:27
See regex101.com/r/5GA6YQ/1
– Wiktor Stribiżew
Mar 22 at 18:27
add a comment |
2 Answers
2
active
oldest
votes
This seems to work for the example cases you provided.
^(?:[A-Za-z]+)(?:d+)(.)
It assumes that the first group is only letters and that the second group is only digits.
add a comment |
There's already a nice answer.
But for the records, your initial proposal was very close to work. You just needed to say that the character matching the 3rd group can repeat several times by adding a star:
^(D+)(d+)(D1)3*
The main weakness is that D
matches any char except digits, so also spaces. Making it more robust leads us to explicit the range of chars accepted:
^([A-Za-z]+)(d+)([A-Za-z]1)3*
It's much better, but my favourite uses w
to match at the end of the pattern any non white character:
([A-Za-z]+)(d+)([A-Za-z]1)w*
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%2f55305759%2fwhat-would-be-the-regex-expression-to-get-the-first-letter-after-a-group-of-char%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This seems to work for the example cases you provided.
^(?:[A-Za-z]+)(?:d+)(.)
It assumes that the first group is only letters and that the second group is only digits.
add a comment |
This seems to work for the example cases you provided.
^(?:[A-Za-z]+)(?:d+)(.)
It assumes that the first group is only letters and that the second group is only digits.
add a comment |
This seems to work for the example cases you provided.
^(?:[A-Za-z]+)(?:d+)(.)
It assumes that the first group is only letters and that the second group is only digits.
This seems to work for the example cases you provided.
^(?:[A-Za-z]+)(?:d+)(.)
It assumes that the first group is only letters and that the second group is only digits.
answered Mar 22 at 18:46
Russ BrownRuss Brown
1516
1516
add a comment |
add a comment |
There's already a nice answer.
But for the records, your initial proposal was very close to work. You just needed to say that the character matching the 3rd group can repeat several times by adding a star:
^(D+)(d+)(D1)3*
The main weakness is that D
matches any char except digits, so also spaces. Making it more robust leads us to explicit the range of chars accepted:
^([A-Za-z]+)(d+)([A-Za-z]1)3*
It's much better, but my favourite uses w
to match at the end of the pattern any non white character:
([A-Za-z]+)(d+)([A-Za-z]1)w*
add a comment |
There's already a nice answer.
But for the records, your initial proposal was very close to work. You just needed to say that the character matching the 3rd group can repeat several times by adding a star:
^(D+)(d+)(D1)3*
The main weakness is that D
matches any char except digits, so also spaces. Making it more robust leads us to explicit the range of chars accepted:
^([A-Za-z]+)(d+)([A-Za-z]1)3*
It's much better, but my favourite uses w
to match at the end of the pattern any non white character:
([A-Za-z]+)(d+)([A-Za-z]1)w*
add a comment |
There's already a nice answer.
But for the records, your initial proposal was very close to work. You just needed to say that the character matching the 3rd group can repeat several times by adding a star:
^(D+)(d+)(D1)3*
The main weakness is that D
matches any char except digits, so also spaces. Making it more robust leads us to explicit the range of chars accepted:
^([A-Za-z]+)(d+)([A-Za-z]1)3*
It's much better, but my favourite uses w
to match at the end of the pattern any non white character:
([A-Za-z]+)(d+)([A-Za-z]1)w*
There's already a nice answer.
But for the records, your initial proposal was very close to work. You just needed to say that the character matching the 3rd group can repeat several times by adding a star:
^(D+)(d+)(D1)3*
The main weakness is that D
matches any char except digits, so also spaces. Making it more robust leads us to explicit the range of chars accepted:
^([A-Za-z]+)(d+)([A-Za-z]1)3*
It's much better, but my favourite uses w
to match at the end of the pattern any non white character:
([A-Za-z]+)(d+)([A-Za-z]1)w*
answered Mar 24 at 22:50
ChristopheChristophe
43.3k43883
43.3k43883
add a comment |
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%2f55305759%2fwhat-would-be-the-regex-expression-to-get-the-first-letter-after-a-group-of-char%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
2
See regex101.com/r/5GA6YQ/1
– Wiktor Stribiżew
Mar 22 at 18:27