Remove Unorder Number From Sublime [closed] - sublimetext3

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
i Have Data Like this
9372127603
9372130412
9372140
9372175041
937218
9372190908
9372191764
i need output like
9372127603
9372130412
9372175041
9372190908
9372191764
what i do to achieve this in sublime text ?

You can do this via regex Find and Replace. Open Find → Replace…, make sure the regex option is on, enter ^\d{1,9}\n into the Find: field, and make sure the Replace: field is empty:
Explanation:
^ beginning of line
\d any digit
{1,9} match preceding between 1 and 9 times, inclusive
\n newline character
test at Regex101
Once you've done that, hit Replace All and any numbers less than 10 digits long will be removed:

Related

Extracting multiple sub strings from a string using regular expresssion [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 days ago.
Improve this question
I want to extract a substring which is present between the closing of the square bracket and opening of the next square brackets without blank spaces using regular expression. There can be multiple square brackets in one particular string.
Example
Input
str1 = '[abc] xyz [zas] bad [ras] kbc'
Output
[xyz, bad, kbc]
One approach here would actually be to use a regex replacement to strip off the [...] terms. Then, split on space to get a list of words/terms you want to keep.
str1 = '[abc] xyz [zas] bad [ras] kbc'
words = re.sub(r'\s*\[.*?\]\s*', ' ', str1).split()
print(words) # ['xyz', 'bad', 'kbc']

How to remove these symbols with sed [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
Upon executing curl I get this kind of a response:
Timestamp:2022-09-19T09:43:15 \n
No:12 \n
Name: Provide a short description \n
Author:jsimpson \n
Description# Description\r\n\r\nThis is the description \r\n\r\n##Provide additional information.\r\n- [X] Address\r\n- [ ] Phone\r\n \n
\r\n
--- \n
How can I remove the following characters using sed command? #, [, ], \r ?
Construction like this can help you to remove these symbols:
sed 's/#//g; s/\[//g; s/\]//g; s/\\r//g'
it is just sequence of changes. Be aware some symbols need to be escaped.

How to replace string in a string but leave string in brackets as it is in python? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I've tried looking but all I came across was how to replace data inside brackets.
What I've been trying to do is, convert
Hello Hello <Hello> hello <hello>
Into
Abc Abc <Hello> abc <hello>
My brain says to add > at start and < at end and use regex to only replace the strings between > < . Tho, I've little to no idea on how to use regex, I think I'll be able to do it like that if I search for it. Still, is there any other neat way to do this?
Thanks.
Assuming the brackets are well-formed and aren't nested, match word characters that aren't inside brackets by using negative lookahead for [^<>]*>.
input = 'Hello Hello <Hello> hello <hello>'
print(re.sub(r'\w+(?![^<>]*>)', 'Abc', input))

Remove entry based on the value of first column [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
If 3549,2152,4701 in first column then remove the entry:
sample data:
18106|1.0.4.0/22
3549|1.0.10.0/24
5413|1.0.0.0/16
2152|1.4.0.0/16
3549|1.0.8.0/22
4701|1.0.0.0/8
Expedted output:
18106|1.0.4.0/22
5413|1.0.0.0/16
How to achieve this?
For your pattern to match only on the first field you have to anchor the expression to the start of the line:
grep -v -E '^(3549|2152|4701)\|'
The ^ marks the beginning of the line (and $ would mark the end of the line)
The -E activates enhanced regular expressions so you don't have to \ escape pipes and parentheses, and the -v inverses the search (returning only lines that do not match).
The ^ matches the start of the line then parentheses with the pipe symbol marks alternatives (3549, 2152 or 4701), and \| stands for the pipe symbol itself which your first field ends with, and needs to be escaped by the backslash so it's not treated as another alternation.
Be careful to use single quotes around it because otherwise the shell itself will interpret some of the special characters.

Vim, search in document header [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need a macro/function that searches the current document, starting at the top, for a specific pattern. Stopping at the first line that isn't commented out.
For example in this vim script:
"This is the first line
"This is the third line
if exists("did_something")
It would stop at if line, return true if it found the pattern and false otherwise.
All help appreciated!
Let's say your pattern is the letter 'e'.
To search for a line that is not commented out, but contains an e:
/^\%(\s*"\)\#!.*e
This uses a negative lookahead (\#!) to confirm that the start of the line (^) isn't followed by a the beginning of a comment (whitespace and then a double quote \s*") but is followed by an 'e' (.*e). The \%( and \) makes the enclosed pattern an atom that other operators (like negative lookahead) can operate on as a unit.
To run a command on matching lines, use :g
:g/^\%(\s*"\)\#!.*e/echo "found one"
To see if the current line matches, use match()
:echo match( getline(line('.')), '^\%(\s*"\)\#!.*e' ) >= 0 ? 'true' : 'false'
The regex is pretty much always the same, the question is what do you want to do with matching lines?

Resources