elisp regular expression build problemRegular expression to match text within quotesTurn case sensitivity off in regular expression replacementProblem in writing regular expression for imenu-generic-expressionRegular expression matching group replacement not workingregular expression whole word replace, whitespace onlyHow to correctly write regular expression to match ASCII control charswhat does grave accent ` and aposrophe ' do in elisp regular expression?
Prove your innocence
Did the British navy fail to take into account the ballistics correction due to Coriolis force during WW1 Falkland Islands battle?
Is using a hyperlink to close a modal a poor design decision?
How to respectfully refuse to assist co-workers with IT issues?
Is “I am getting married with my sister” ambiguous?
Is for(( ... )) ... ; a valid shell syntax? In which shells?
Confirming resignation after resignation letter ripped up
Fried gnocchi with spinach, bacon, cream sauce in a single pan
What is the difference between Major and Minor Bug?
Does norwegian.no airline overbook flights?
Are the players on the same team as the DM?
Why did they avoid parodying Martian Manhunter?
Mathematical uses of string theory
Identify this sanskrit mantra?
Identify a problem where a potentially winning move draws because of the 50 move rule
Efficiently pathfinding many flocking enemies around obstacles
Can you upsert using Composite SObject Tree?
How to get the current pages Page Design in code
What to say to a student who has failed?
What is the history of the university asylum law?
Would it be possible to have a GMO that produces chocolate?
Why were the crew so desperate to catch Truman and return him to Seahaven?
Sci fi film similar to Village of the Damned
Is gzip atomic?
elisp regular expression build problem
Regular expression to match text within quotesTurn case sensitivity off in regular expression replacementProblem in writing regular expression for imenu-generic-expressionRegular expression matching group replacement not workingregular expression whole word replace, whitespace onlyHow to correctly write regular expression to match ASCII control charswhat does grave accent ` and aposrophe ' do in elisp regular expression?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have the following line :
mod_name func_name /users/username/workspace/path_name/file.c 283
I wanted to capture the 3rd and 4th entry in this line, I am able
to do that using regular expressions like so: ^(?:S+s)2(S+) ([0-9]+)
How do I translate this into a lisp regex ? so that elisp functions can
understand. I couldn't use the above regex into re-builder within emacs. Says it is an invalid expression. What am I doing wrong ?
regular-expressions
add a comment |
I have the following line :
mod_name func_name /users/username/workspace/path_name/file.c 283
I wanted to capture the 3rd and 4th entry in this line, I am able
to do that using regular expressions like so: ^(?:S+s)2(S+) ([0-9]+)
How do I translate this into a lisp regex ? so that elisp functions can
understand. I couldn't use the above regex into re-builder within emacs. Says it is an invalid expression. What am I doing wrong ?
regular-expressions
1
Different regex syntaxes compared
– Gilles♦
Aug 12 at 8:44
add a comment |
I have the following line :
mod_name func_name /users/username/workspace/path_name/file.c 283
I wanted to capture the 3rd and 4th entry in this line, I am able
to do that using regular expressions like so: ^(?:S+s)2(S+) ([0-9]+)
How do I translate this into a lisp regex ? so that elisp functions can
understand. I couldn't use the above regex into re-builder within emacs. Says it is an invalid expression. What am I doing wrong ?
regular-expressions
I have the following line :
mod_name func_name /users/username/workspace/path_name/file.c 283
I wanted to capture the 3rd and 4th entry in this line, I am able
to do that using regular expressions like so: ^(?:S+s)2(S+) ([0-9]+)
How do I translate this into a lisp regex ? so that elisp functions can
understand. I couldn't use the above regex into re-builder within emacs. Says it is an invalid expression. What am I doing wrong ?
regular-expressions
regular-expressions
edited Aug 12 at 0:15
Drew
50.9k4 gold badges65 silver badges114 bronze badges
50.9k4 gold badges65 silver badges114 bronze badges
asked Aug 11 at 19:35
maindoormaindoor
254 bronze badges
254 bronze badges
1
Different regex syntaxes compared
– Gilles♦
Aug 12 at 8:44
add a comment |
1
Different regex syntaxes compared
– Gilles♦
Aug 12 at 8:44
1
1
Different regex syntaxes compared
– Gilles♦
Aug 12 at 8:44
Different regex syntaxes compared
– Gilles♦
Aug 12 at 8:44
add a comment |
1 Answer
1
active
oldest
votes
Emacs regexps do not use S or s for non-whitespace and whitepsace. See (info "(elisp) Syntax of Regexps") for details. You can evaluate that which will jump to the corresponding info page.
It's far easier and more readable to use the rx macro to create regexps in Emacs. Here is my translation to rx syntax of your example:
(rx line-start
(= 2 (and (one-or-more any) " "))
(group (one-or-more any))
" "
(group (one-or-more digit)))
And here is resulting regex string:
"^\(?:.+ \)\2\\(.+\) \([0-9]+\)"
Note that any which is expressed in regexps as "." does not match newlines in Emacs.
Thank you explaining rx macro.
– maindoor
Aug 11 at 23:50
@Drew Thanks for editing!
– clemera
Aug 12 at 5:10
1
'**any**which is expressed in regexps as "." does not match newlines in Emacs.' - you can also write it asnot-newlineornonlto make that clearer.
– npostavs
Aug 12 at 13:13
@npostavs Thanks, nice to know!
– clemera
Aug 12 at 13:19
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "583"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2femacs.stackexchange.com%2fquestions%2f52114%2felisp-regular-expression-build-problem%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
Emacs regexps do not use S or s for non-whitespace and whitepsace. See (info "(elisp) Syntax of Regexps") for details. You can evaluate that which will jump to the corresponding info page.
It's far easier and more readable to use the rx macro to create regexps in Emacs. Here is my translation to rx syntax of your example:
(rx line-start
(= 2 (and (one-or-more any) " "))
(group (one-or-more any))
" "
(group (one-or-more digit)))
And here is resulting regex string:
"^\(?:.+ \)\2\\(.+\) \([0-9]+\)"
Note that any which is expressed in regexps as "." does not match newlines in Emacs.
Thank you explaining rx macro.
– maindoor
Aug 11 at 23:50
@Drew Thanks for editing!
– clemera
Aug 12 at 5:10
1
'**any**which is expressed in regexps as "." does not match newlines in Emacs.' - you can also write it asnot-newlineornonlto make that clearer.
– npostavs
Aug 12 at 13:13
@npostavs Thanks, nice to know!
– clemera
Aug 12 at 13:19
add a comment |
Emacs regexps do not use S or s for non-whitespace and whitepsace. See (info "(elisp) Syntax of Regexps") for details. You can evaluate that which will jump to the corresponding info page.
It's far easier and more readable to use the rx macro to create regexps in Emacs. Here is my translation to rx syntax of your example:
(rx line-start
(= 2 (and (one-or-more any) " "))
(group (one-or-more any))
" "
(group (one-or-more digit)))
And here is resulting regex string:
"^\(?:.+ \)\2\\(.+\) \([0-9]+\)"
Note that any which is expressed in regexps as "." does not match newlines in Emacs.
Thank you explaining rx macro.
– maindoor
Aug 11 at 23:50
@Drew Thanks for editing!
– clemera
Aug 12 at 5:10
1
'**any**which is expressed in regexps as "." does not match newlines in Emacs.' - you can also write it asnot-newlineornonlto make that clearer.
– npostavs
Aug 12 at 13:13
@npostavs Thanks, nice to know!
– clemera
Aug 12 at 13:19
add a comment |
Emacs regexps do not use S or s for non-whitespace and whitepsace. See (info "(elisp) Syntax of Regexps") for details. You can evaluate that which will jump to the corresponding info page.
It's far easier and more readable to use the rx macro to create regexps in Emacs. Here is my translation to rx syntax of your example:
(rx line-start
(= 2 (and (one-or-more any) " "))
(group (one-or-more any))
" "
(group (one-or-more digit)))
And here is resulting regex string:
"^\(?:.+ \)\2\\(.+\) \([0-9]+\)"
Note that any which is expressed in regexps as "." does not match newlines in Emacs.
Emacs regexps do not use S or s for non-whitespace and whitepsace. See (info "(elisp) Syntax of Regexps") for details. You can evaluate that which will jump to the corresponding info page.
It's far easier and more readable to use the rx macro to create regexps in Emacs. Here is my translation to rx syntax of your example:
(rx line-start
(= 2 (and (one-or-more any) " "))
(group (one-or-more any))
" "
(group (one-or-more digit)))
And here is resulting regex string:
"^\(?:.+ \)\2\\(.+\) \([0-9]+\)"
Note that any which is expressed in regexps as "." does not match newlines in Emacs.
edited Aug 12 at 0:19
Drew
50.9k4 gold badges65 silver badges114 bronze badges
50.9k4 gold badges65 silver badges114 bronze badges
answered Aug 11 at 21:27
clemeraclemera
2,1607 silver badges26 bronze badges
2,1607 silver badges26 bronze badges
Thank you explaining rx macro.
– maindoor
Aug 11 at 23:50
@Drew Thanks for editing!
– clemera
Aug 12 at 5:10
1
'**any**which is expressed in regexps as "." does not match newlines in Emacs.' - you can also write it asnot-newlineornonlto make that clearer.
– npostavs
Aug 12 at 13:13
@npostavs Thanks, nice to know!
– clemera
Aug 12 at 13:19
add a comment |
Thank you explaining rx macro.
– maindoor
Aug 11 at 23:50
@Drew Thanks for editing!
– clemera
Aug 12 at 5:10
1
'**any**which is expressed in regexps as "." does not match newlines in Emacs.' - you can also write it asnot-newlineornonlto make that clearer.
– npostavs
Aug 12 at 13:13
@npostavs Thanks, nice to know!
– clemera
Aug 12 at 13:19
Thank you explaining rx macro.
– maindoor
Aug 11 at 23:50
Thank you explaining rx macro.
– maindoor
Aug 11 at 23:50
@Drew Thanks for editing!
– clemera
Aug 12 at 5:10
@Drew Thanks for editing!
– clemera
Aug 12 at 5:10
1
1
'
**any** which is expressed in regexps as "." does not match newlines in Emacs.' - you can also write it as not-newline or nonl to make that clearer.– npostavs
Aug 12 at 13:13
'
**any** which is expressed in regexps as "." does not match newlines in Emacs.' - you can also write it as not-newline or nonl to make that clearer.– npostavs
Aug 12 at 13:13
@npostavs Thanks, nice to know!
– clemera
Aug 12 at 13:19
@npostavs Thanks, nice to know!
– clemera
Aug 12 at 13:19
add a comment |
Thanks for contributing an answer to Emacs Stack Exchange!
- 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%2femacs.stackexchange.com%2fquestions%2f52114%2felisp-regular-expression-build-problem%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
1
Different regex syntaxes compared
– Gilles♦
Aug 12 at 8:44