Parsing: extract a version from a html line
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I would like to extract version number from this string:
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
Note that '/url/version/tree/
' may change (ex: from /url/version/tree/
to /url/version2/tree1/)
and version may change too (ex: from 1.01alpha11
to 2.0stable
)
Ideas/suggestions?
linux text-processing html
add a comment |Â
up vote
0
down vote
favorite
I would like to extract version number from this string:
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
Note that '/url/version/tree/
' may change (ex: from /url/version/tree/
to /url/version2/tree1/)
and version may change too (ex: from 1.01alpha11
to 2.0stable
)
Ideas/suggestions?
linux text-processing html
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to extract version number from this string:
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
Note that '/url/version/tree/
' may change (ex: from /url/version/tree/
to /url/version2/tree1/)
and version may change too (ex: from 1.01alpha11
to 2.0stable
)
Ideas/suggestions?
linux text-processing html
I would like to extract version number from this string:
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
Note that '/url/version/tree/
' may change (ex: from /url/version/tree/
to /url/version2/tree1/)
and version may change too (ex: from 1.01alpha11
to 2.0stable
)
Ideas/suggestions?
linux text-processing html
edited Jan 14 at 11:38
Jeff Schaller
31.8k848109
31.8k848109
asked Jan 14 at 10:05
piplo
1
1
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
0
down vote
sed
solution:
Sample file input.txt
:
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
<a href="/url/version/tree/2.0stable" class="css-truncate">
sed -En 's@.*<href="/[^[:space:]]+/([^/"[:space:]]+).*@1@p' input.txt
The output:
1.0.1alpha11
1.0.2alpha11
2.0stable
add a comment |Â
up vote
0
down vote
I extracted the version by using below awk command. As tested its worked fine.
Inputfile
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
<a href="/url/version/tree/2.0stable" class="css-truncate">
command
awk -F '[/]' 'print $NF' Inputfile| awk -F '"' 'print $1'
output
1.0.1alpha11
1.0.2alpha11
2.0stable
add a comment |Â
up vote
0
down vote
Source file: input.txt:
<a href="/url/version2/tree1/2.0stable" class="css-truncate">
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
Using awk
and sed
:
awk 'BEGIN FS = "/" print $5 ' input.txt | sed -E 's/^(.*)"s.*/1/'
Results:
2.0stable
1.0.1alpha11
1.0.2alpha11
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
sed
solution:
Sample file input.txt
:
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
<a href="/url/version/tree/2.0stable" class="css-truncate">
sed -En 's@.*<href="/[^[:space:]]+/([^/"[:space:]]+).*@1@p' input.txt
The output:
1.0.1alpha11
1.0.2alpha11
2.0stable
add a comment |Â
up vote
0
down vote
sed
solution:
Sample file input.txt
:
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
<a href="/url/version/tree/2.0stable" class="css-truncate">
sed -En 's@.*<href="/[^[:space:]]+/([^/"[:space:]]+).*@1@p' input.txt
The output:
1.0.1alpha11
1.0.2alpha11
2.0stable
add a comment |Â
up vote
0
down vote
up vote
0
down vote
sed
solution:
Sample file input.txt
:
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
<a href="/url/version/tree/2.0stable" class="css-truncate">
sed -En 's@.*<href="/[^[:space:]]+/([^/"[:space:]]+).*@1@p' input.txt
The output:
1.0.1alpha11
1.0.2alpha11
2.0stable
sed
solution:
Sample file input.txt
:
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
<a href="/url/version/tree/2.0stable" class="css-truncate">
sed -En 's@.*<href="/[^[:space:]]+/([^/"[:space:]]+).*@1@p' input.txt
The output:
1.0.1alpha11
1.0.2alpha11
2.0stable
answered Jan 14 at 11:06
RomanPerekhrest
22.4k12144
22.4k12144
add a comment |Â
add a comment |Â
up vote
0
down vote
I extracted the version by using below awk command. As tested its worked fine.
Inputfile
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
<a href="/url/version/tree/2.0stable" class="css-truncate">
command
awk -F '[/]' 'print $NF' Inputfile| awk -F '"' 'print $1'
output
1.0.1alpha11
1.0.2alpha11
2.0stable
add a comment |Â
up vote
0
down vote
I extracted the version by using below awk command. As tested its worked fine.
Inputfile
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
<a href="/url/version/tree/2.0stable" class="css-truncate">
command
awk -F '[/]' 'print $NF' Inputfile| awk -F '"' 'print $1'
output
1.0.1alpha11
1.0.2alpha11
2.0stable
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I extracted the version by using below awk command. As tested its worked fine.
Inputfile
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
<a href="/url/version/tree/2.0stable" class="css-truncate">
command
awk -F '[/]' 'print $NF' Inputfile| awk -F '"' 'print $1'
output
1.0.1alpha11
1.0.2alpha11
2.0stable
I extracted the version by using below awk command. As tested its worked fine.
Inputfile
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
<a href="/url/version/tree/2.0stable" class="css-truncate">
command
awk -F '[/]' 'print $NF' Inputfile| awk -F '"' 'print $1'
output
1.0.1alpha11
1.0.2alpha11
2.0stable
edited Jan 14 at 11:28
answered Jan 14 at 11:20
Praveen Kumar BS
1,010128
1,010128
add a comment |Â
add a comment |Â
up vote
0
down vote
Source file: input.txt:
<a href="/url/version2/tree1/2.0stable" class="css-truncate">
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
Using awk
and sed
:
awk 'BEGIN FS = "/" print $5 ' input.txt | sed -E 's/^(.*)"s.*/1/'
Results:
2.0stable
1.0.1alpha11
1.0.2alpha11
add a comment |Â
up vote
0
down vote
Source file: input.txt:
<a href="/url/version2/tree1/2.0stable" class="css-truncate">
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
Using awk
and sed
:
awk 'BEGIN FS = "/" print $5 ' input.txt | sed -E 's/^(.*)"s.*/1/'
Results:
2.0stable
1.0.1alpha11
1.0.2alpha11
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Source file: input.txt:
<a href="/url/version2/tree1/2.0stable" class="css-truncate">
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
Using awk
and sed
:
awk 'BEGIN FS = "/" print $5 ' input.txt | sed -E 's/^(.*)"s.*/1/'
Results:
2.0stable
1.0.1alpha11
1.0.2alpha11
Source file: input.txt:
<a href="/url/version2/tree1/2.0stable" class="css-truncate">
<a href="/url/version/tree/1.0.1alpha11" class="css-truncate">
<a href="/url/version2/tree1/1.0.2alpha11" class="css-truncate">
Using awk
and sed
:
awk 'BEGIN FS = "/" print $5 ' input.txt | sed -E 's/^(.*)"s.*/1/'
Results:
2.0stable
1.0.1alpha11
1.0.2alpha11
edited Jan 14 at 11:52
answered Jan 14 at 11:46
George Udosen
1,112318
1,112318
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416993%2fparsing-extract-a-version-from-a-html-line%23new-answer', 'question_page');
);
Post as a guest
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
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
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