Scripts: how to remove hex strings in a text file [closed] - regex

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
The input file is like
<org.eclipse.core.runtime.adaptor.EclipseClassLoader#1c7d9114,Lorg/eclipse/core/
resources/ResourcesPlugin;>.<init>(Lorg/eclipse/core/runtime/IPluginDescriptor;)V
the goal is to remove hex strings like 1c7d9114,.
The length of the hex strings is fixed, that is 8.
please also include the immediate following comma.
Is there any simple script could deal with this?

Using sed:
sed 's/#[a-f0-9]\{8\},/#/' input

Using perl:
perl -pe 's/\#[a-f0-9]{8},/\#/' input.txt
Using awk:
awk '{gsub(/#[a-f0-9]{8},/,"#",$0)}1' input.txt

Related

Weird grep corner case? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
If I have a file named 'test' with text literally:
\<.abc\>
and then run grep -E 'abc\> | [1-5]' test, I get no results as expected,
but when I run just grep -E 'abc\>' test, I get a match!
Why is this?
It looks like this problem was solved, but one other follow-up question:
If I wanted to use a regex like 'abc>' and for there to be no results (because no word ends with abc), how can I do this? (I also want to keep the quotes so that I can expand the regex).
grep -E 'abc\> | [1-5]' test, I get no results as expected
because you added spaces before and after the |, try:
grep -E 'abc\>|[1-5]' test
test here:
kent$ grep -E 'abc\>|[1-5]' <<<'\<.abc\>'
\<.abc\>

Regex For Simple Pattern Matching [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How would one create a regex for a string containing alphanumeric characters to match everything including and after the first occurrence of a numeric character?
example
HdeTT55679HHdsdd
would match
55679HHdsdd
and
re678TTHY88
would match
678TTHY88
thanks in advance
[0-9].*
this will match anything after a number
If you are sure that the string only contains alnum characters, then you can simply match
[0-9].*
If not, use
[0-9][A-Za-z0-9]*
use this regular expression \d.+
If you're using PCRE, the following might work for you:
'[^\d]*\K.*'
For example:
$ echo HdeTT55679HHdsdd | grep -oP '[^\d]*\K.*'
55679HHdsdd
$ echo re678TTHY88 | grep -oP '[^\d]*\K.*'
678TTHY88

How would you parse in bash #extra_modules <string> [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How would I parse
#extra_modules some string
in kdump.conf file to get "some string" as actual output in bash script ?
Thanks !
grep "#extra_modules" kdump.conf | cut -c 16-
grep finds the lines with the phrase "#extra_modules", and cut selects all the characters after the first space

Extract the email address, and replacing a character using Regex [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am trying to come up with Reg ex expression that would match an email address starting with format E- and replacing the "AT" with an actual "#" sign.
Here is an example:
E-CANAD.JACK AT EXAMPLE.COM.
The desired output will need to look like CANAD.JACK#EXAMPLE.COM.
Replace:
[eE]-([a-zA-Z0-9]+(?:[._-][a-zA-Z0-9]+)*) (?:at|AT) ([a-zA-Z0-9]+(?:[._-][a-zA-Z0-9]+)*[.][a-zA-Z]+)
By:
$1#$2
More:
Visualization by
Debuggex
Demo by RegExr
You didn't mention your language, so I'm assuming perl
s/^E-(.*) AT (.*)$/$1\#$2/;

Format a C++ string with template [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
What is the best way to transform a string with a special template, like a sed unix transform.
i must to do this with QT c++ :
original string : 00048500854006F85FF4B0
before c++ transform : 48500854006F85FF4B
Eliminate all the 0 in the start and the end of my string (not in the middle).
maybe a solution with sprintf ?
thank you very much for your help.
It's possible to do using regular expression:
QString("00048500854006F85FF4B0").remove(QRegExp("(^(0)+)|((0)+$)"));
You can always use the power of sed by calling system ("sed 's/foo/bar/' file"); or by using the Qt QProcess. In that case see this and this