Skip to main content
more specific edit
Source Link
db48x
  • 19.1k
  • 1
  • 24
  • 29

The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit). It is better to rephrase this type of question to ask how to do something, rather than merely if it is possible, since that's usually what most people mean by it. It's also a good idea to list what you've already tried, and possibly why that didn't work.

You want to use the seq-filterremove function. You can read the documentation for it by typing C-h f seq-filterremove <RET>. You'll see that it takes a predicate function and a sequence, and returns a new sequence comprised of those elements for which the predicate function returns truenil.

For the predicate, I recommend writing a lambda that calls string-match-p. This returns true when a string matches a regular expression. Again, you can see the documentation for functions with C-h f.

Putting those together, something like this ought to work:

(seq-filterremove (lambda (line)
              (string-match-p "^\\*+ " line))
            your-list-of-strings)

The elisp manual includes additional documentation about these topics that you might want to read, along with documentation about similar functions that you may soon need. You can open the info browser with C-h i. You may have many info manuals installed on your computer, but you should specifically take a look at the Emacs manual and the Elisp manual. Chapters 6.1 Sequences and 34.4 Regular Expression Searching would be good places to start.

Update: good catch, I did invert the sense of the test. As was mentioned in the comments, using seq-remove in place of seq-filter will do it correctly.

The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit). It is better to rephrase this type of question to ask how to do something, rather than merely if it is possible, since that's usually what most people mean by it. It's also a good idea to list what you've already tried, and possibly why that didn't work.

You want to use the seq-filter function. You can read the documentation for it by typing C-h f seq-filter <RET>. You'll see that it takes a predicate function and a sequence, and returns a new sequence comprised of those elements for which the predicate function returns true.

For the predicate, I recommend writing a lambda that calls string-match-p. This returns true when a string matches a regular expression. Again, you can see the documentation for functions with C-h f.

Putting those together, something like this ought to work:

(seq-filter (lambda (line)
              (string-match-p "^\\*+ " line))
            your-list-of-strings)

The elisp manual includes additional documentation about these topics that you might want to read, along with documentation about similar functions that you may soon need. You can open the info browser with C-h i. You may have many info manuals installed on your computer, but you should specifically take a look at the Emacs manual and the Elisp manual. Chapters 6.1 Sequences and 34.4 Regular Expression Searching would be good places to start.

Update: good catch, I did invert the sense of the test. As was mentioned in the comments, using seq-remove in place of seq-filter will do it correctly.

The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit). It is better to rephrase this type of question to ask how to do something, rather than merely if it is possible, since that's usually what most people mean by it. It's also a good idea to list what you've already tried, and possibly why that didn't work.

You want to use the seq-remove function. You can read the documentation for it by typing C-h f seq-remove <RET>. You'll see that it takes a predicate function and a sequence, and returns a new sequence comprised of those elements for which the predicate function returns nil.

For the predicate, I recommend writing a lambda that calls string-match-p. This returns true when a string matches a regular expression. Again, you can see the documentation for functions with C-h f.

Putting those together, something like this ought to work:

(seq-remove (lambda (line)
              (string-match-p "^\\*+ " line))
            your-list-of-strings)

The elisp manual includes additional documentation about these topics that you might want to read, along with documentation about similar functions that you may soon need. You can open the info browser with C-h i. You may have many info manuals installed on your computer, but you should specifically take a look at the Emacs manual and the Elisp manual. Chapters 6.1 Sequences and 34.4 Regular Expression Searching would be good places to start.

seq-remove
Source Link
db48x
  • 19.1k
  • 1
  • 24
  • 29

The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit). It is better to rephrase this type of question to ask how to do something, rather than merely if it is possible, since that's usually what most people mean by it. It's also a good idea to list what you've already tried, and possibly why that didn't work.

You want to use the seq-filter function. You can read the documentation for it by typing C-h f seq-filter <RET>. You'll see that it takes a predicate function and a sequence, and returns a new sequence comprised of those elements for which the predicate function returns true.

For the predicate, I recommend writing a lambda that calls string-match-p. This returns true when a string matches a regular expression. Again, you can see the documentation for functions with C-h f.

Putting those together, something like this ought to work:

(seq-filter (lambda (line)
              (string-match-p "^\\*+ " line))
            your-list-of-strings)

The elisp manual includes additional documentation about these topics that you might want to read, along with documentation about similar functions that you may soon need. You can open the info browser with C-h i. You may have many info manuals installed on your computer, but you should specifically take a look at the Emacs manual and the Elisp manual. Chapters 6.1 Sequences and 34.4 Regular Expression Searching would be good places to start.

Update: good catch, I did invert the sense of the test. As was mentioned in the comments, using seq-remove in place of seq-filter will do it correctly.

The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit). It is better to rephrase this type of question to ask how to do something, rather than merely if it is possible, since that's usually what most people mean by it. It's also a good idea to list what you've already tried, and possibly why that didn't work.

You want to use the seq-filter function. You can read the documentation for it by typing C-h f seq-filter <RET>. You'll see that it takes a predicate function and a sequence, and returns a new sequence comprised of those elements for which the predicate function returns true.

For the predicate, I recommend writing a lambda that calls string-match-p. This returns true when a string matches a regular expression. Again, you can see the documentation for functions with C-h f.

Putting those together, something like this ought to work:

(seq-filter (lambda (line)
              (string-match-p "^\\*+ " line))
            your-list-of-strings)

The elisp manual includes additional documentation about these topics that you might want to read, along with documentation about similar functions that you may soon need. You can open the info browser with C-h i. You may have many info manuals installed on your computer, but you should specifically take a look at the Emacs manual and the Elisp manual. Chapters 6.1 Sequences and 34.4 Regular Expression Searching would be good places to start.

The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit). It is better to rephrase this type of question to ask how to do something, rather than merely if it is possible, since that's usually what most people mean by it. It's also a good idea to list what you've already tried, and possibly why that didn't work.

You want to use the seq-filter function. You can read the documentation for it by typing C-h f seq-filter <RET>. You'll see that it takes a predicate function and a sequence, and returns a new sequence comprised of those elements for which the predicate function returns true.

For the predicate, I recommend writing a lambda that calls string-match-p. This returns true when a string matches a regular expression. Again, you can see the documentation for functions with C-h f.

Putting those together, something like this ought to work:

(seq-filter (lambda (line)
              (string-match-p "^\\*+ " line))
            your-list-of-strings)

The elisp manual includes additional documentation about these topics that you might want to read, along with documentation about similar functions that you may soon need. You can open the info browser with C-h i. You may have many info manuals installed on your computer, but you should specifically take a look at the Emacs manual and the Elisp manual. Chapters 6.1 Sequences and 34.4 Regular Expression Searching would be good places to start.

Update: good catch, I did invert the sense of the test. As was mentioned in the comments, using seq-remove in place of seq-filter will do it correctly.

update the regexp
Source Link
db48x
  • 19.1k
  • 1
  • 24
  • 29

The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit). It is better to rephrase this type of question to ask how to do something, rather than merely if it is possible, since that's usually what most people mean by it. It's also a good idea to list what you've already tried, and possibly why that didn't work.

You want to use the seq-filter function. You can read the documentation for it by typing C-h f seq-filter <RET>. You'll see that it takes a predicate function and a sequence, and returns a new sequence comprised of those elements for which the predicate function returns true.

For the predicate, I recommend writing a lambda that calls string-match-p. This returns true when a string matches a regular expression. Again, you can see the documentation for functions with C-h f.

Putting those together, something like this ought to work:

(seq-filter (lambda (line)
              (string-match-p "^\\*""^\\*+ " line))
            your-list-of-strings)

The elisp manual includes additional documentation about these topics that you might want to read, along with documentation about similar functions that you may soon need. You can open the info browser with C-h i. You may have many info manuals installed on your computer, but you should specifically take a look at the Emacs manual and the Elisp manual. Chapters 6.1 Sequences and 34.4 Regular Expression Searching would be good places to start.

The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit). It is better to rephrase this type of question to ask how to do something, rather than merely if it is possible, since that's usually what most people mean by it. It's also a good idea to list what you've already tried, and possibly why that didn't work.

You want to use the seq-filter function. You can read the documentation for it by typing C-h f seq-filter <RET>. You'll see that it takes a predicate function and a sequence, and returns a new sequence comprised of those elements for which the predicate function returns true.

For the predicate, I recommend writing a lambda that calls string-match-p. This returns true when a string matches a regular expression. Again, you can see the documentation for functions with C-h f.

Putting those together, something like this ought to work:

(seq-filter (lambda (line)
              (string-match-p "^\\*" line))
            your-list-of-strings)

The elisp manual includes additional documentation about these topics that you might want to read, along with documentation about similar functions that you may soon need. You can open the info browser with C-h i. You may have many info manuals installed on your computer, but you should specifically take a look at the Emacs manual and the Elisp manual. Chapters 6.1 Sequences and 34.4 Regular Expression Searching would be good places to start.

The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit). It is better to rephrase this type of question to ask how to do something, rather than merely if it is possible, since that's usually what most people mean by it. It's also a good idea to list what you've already tried, and possibly why that didn't work.

You want to use the seq-filter function. You can read the documentation for it by typing C-h f seq-filter <RET>. You'll see that it takes a predicate function and a sequence, and returns a new sequence comprised of those elements for which the predicate function returns true.

For the predicate, I recommend writing a lambda that calls string-match-p. This returns true when a string matches a regular expression. Again, you can see the documentation for functions with C-h f.

Putting those together, something like this ought to work:

(seq-filter (lambda (line)
              (string-match-p "^\\*+ " line))
            your-list-of-strings)

The elisp manual includes additional documentation about these topics that you might want to read, along with documentation about similar functions that you may soon need. You can open the info browser with C-h i. You may have many info manuals installed on your computer, but you should specifically take a look at the Emacs manual and the Elisp manual. Chapters 6.1 Sequences and 34.4 Regular Expression Searching would be good places to start.

Source Link
db48x
  • 19.1k
  • 1
  • 24
  • 29
Loading