Make character in tag uppercase and remove tag

Multi tool use
up vote
-3
down vote
favorite
How to make a character between a tag uppercase?
For example I have this string:
string = "<big>t<big>his should be <big>u<big>ppercase"
Should result in:
This should be Uppercase
python string
|
show 2 more comments
up vote
-3
down vote
favorite
How to make a character between a tag uppercase?
For example I have this string:
string = "<big>t<big>his should be <big>u<big>ppercase"
Should result in:
This should be Uppercase
python string
1
I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable namestr
is reserved!!
– Anton vBR
yesterday
is <big> even a real tag?
– Paritosh Singh
yesterday
It's not a real tag, just for example.
– rw026
yesterday
Normally you'd expect the closing tag to be</big>
– khelwood
yesterday
Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
– Paritosh Singh
yesterday
|
show 2 more comments
up vote
-3
down vote
favorite
up vote
-3
down vote
favorite
How to make a character between a tag uppercase?
For example I have this string:
string = "<big>t<big>his should be <big>u<big>ppercase"
Should result in:
This should be Uppercase
python string
How to make a character between a tag uppercase?
For example I have this string:
string = "<big>t<big>his should be <big>u<big>ppercase"
Should result in:
This should be Uppercase
python string
python string
edited yesterday
asked yesterday


rw026
155
155
1
I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable namestr
is reserved!!
– Anton vBR
yesterday
is <big> even a real tag?
– Paritosh Singh
yesterday
It's not a real tag, just for example.
– rw026
yesterday
Normally you'd expect the closing tag to be</big>
– khelwood
yesterday
Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
– Paritosh Singh
yesterday
|
show 2 more comments
1
I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable namestr
is reserved!!
– Anton vBR
yesterday
is <big> even a real tag?
– Paritosh Singh
yesterday
It's not a real tag, just for example.
– rw026
yesterday
Normally you'd expect the closing tag to be</big>
– khelwood
yesterday
Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
– Paritosh Singh
yesterday
1
1
I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable name
str
is reserved!!– Anton vBR
yesterday
I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable name
str
is reserved!!– Anton vBR
yesterday
is <big> even a real tag?
– Paritosh Singh
yesterday
is <big> even a real tag?
– Paritosh Singh
yesterday
It's not a real tag, just for example.
– rw026
yesterday
It's not a real tag, just for example.
– rw026
yesterday
Normally you'd expect the closing tag to be
</big>
– khelwood
yesterday
Normally you'd expect the closing tag to be
</big>
– khelwood
yesterday
Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
– Paritosh Singh
yesterday
Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
– Paritosh Singh
yesterday
|
show 2 more comments
3 Answers
3
active
oldest
votes
up vote
1
down vote
Constantly as longest as there's < big> in txt remove tags and uppercase the text between them
def up(x):
idx1 = x.index('<big>')
idx2 = x.index('<big>', idx1+1)
new_x = x[:idx1]
new_x += x[idx1+5: idx2].upper()
new_x += x[idx2+5:]
return new_x
txt = "<big>t<big>his should be <big>u<big>ppercase"
while '<big>' in txt:
txt = up(txt)
print(txt) # This should be Uppercase
add a comment |
up vote
1
down vote
Try this:
import re
s="<big>t<big>his should be <big>u<big>ppercase"
result = re.finditer('<big>(.)<big>', s)
for i in result:
s = s.replace(i.group(0), i.group(1).upper())
Note:
Do not use
str
as a name of a variable.str
is predefined in python.
add a comment |
up vote
0
down vote
Those don't look like real xml tags. But assuming the number of <big>
tags are used correctly, you can split it by tag and apply upper()
to strings between.
text = "<big>t<big>his should be <big>u<big>ppercase"
split_str = text.split('<big>')
result = ''.join([x.upper() if i % 2 else x for i, x in enumerate(split_str)])
New contributor
boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Constantly as longest as there's < big> in txt remove tags and uppercase the text between them
def up(x):
idx1 = x.index('<big>')
idx2 = x.index('<big>', idx1+1)
new_x = x[:idx1]
new_x += x[idx1+5: idx2].upper()
new_x += x[idx2+5:]
return new_x
txt = "<big>t<big>his should be <big>u<big>ppercase"
while '<big>' in txt:
txt = up(txt)
print(txt) # This should be Uppercase
add a comment |
up vote
1
down vote
Constantly as longest as there's < big> in txt remove tags and uppercase the text between them
def up(x):
idx1 = x.index('<big>')
idx2 = x.index('<big>', idx1+1)
new_x = x[:idx1]
new_x += x[idx1+5: idx2].upper()
new_x += x[idx2+5:]
return new_x
txt = "<big>t<big>his should be <big>u<big>ppercase"
while '<big>' in txt:
txt = up(txt)
print(txt) # This should be Uppercase
add a comment |
up vote
1
down vote
up vote
1
down vote
Constantly as longest as there's < big> in txt remove tags and uppercase the text between them
def up(x):
idx1 = x.index('<big>')
idx2 = x.index('<big>', idx1+1)
new_x = x[:idx1]
new_x += x[idx1+5: idx2].upper()
new_x += x[idx2+5:]
return new_x
txt = "<big>t<big>his should be <big>u<big>ppercase"
while '<big>' in txt:
txt = up(txt)
print(txt) # This should be Uppercase
Constantly as longest as there's < big> in txt remove tags and uppercase the text between them
def up(x):
idx1 = x.index('<big>')
idx2 = x.index('<big>', idx1+1)
new_x = x[:idx1]
new_x += x[idx1+5: idx2].upper()
new_x += x[idx2+5:]
return new_x
txt = "<big>t<big>his should be <big>u<big>ppercase"
while '<big>' in txt:
txt = up(txt)
print(txt) # This should be Uppercase
edited yesterday
answered yesterday
Looioe
845
845
add a comment |
add a comment |
up vote
1
down vote
Try this:
import re
s="<big>t<big>his should be <big>u<big>ppercase"
result = re.finditer('<big>(.)<big>', s)
for i in result:
s = s.replace(i.group(0), i.group(1).upper())
Note:
Do not use
str
as a name of a variable.str
is predefined in python.
add a comment |
up vote
1
down vote
Try this:
import re
s="<big>t<big>his should be <big>u<big>ppercase"
result = re.finditer('<big>(.)<big>', s)
for i in result:
s = s.replace(i.group(0), i.group(1).upper())
Note:
Do not use
str
as a name of a variable.str
is predefined in python.
add a comment |
up vote
1
down vote
up vote
1
down vote
Try this:
import re
s="<big>t<big>his should be <big>u<big>ppercase"
result = re.finditer('<big>(.)<big>', s)
for i in result:
s = s.replace(i.group(0), i.group(1).upper())
Note:
Do not use
str
as a name of a variable.str
is predefined in python.
Try this:
import re
s="<big>t<big>his should be <big>u<big>ppercase"
result = re.finditer('<big>(.)<big>', s)
for i in result:
s = s.replace(i.group(0), i.group(1).upper())
Note:
Do not use
str
as a name of a variable.str
is predefined in python.
answered yesterday
mehrdad-pedramfar
3,32511232
3,32511232
add a comment |
add a comment |
up vote
0
down vote
Those don't look like real xml tags. But assuming the number of <big>
tags are used correctly, you can split it by tag and apply upper()
to strings between.
text = "<big>t<big>his should be <big>u<big>ppercase"
split_str = text.split('<big>')
result = ''.join([x.upper() if i % 2 else x for i, x in enumerate(split_str)])
New contributor
boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
Those don't look like real xml tags. But assuming the number of <big>
tags are used correctly, you can split it by tag and apply upper()
to strings between.
text = "<big>t<big>his should be <big>u<big>ppercase"
split_str = text.split('<big>')
result = ''.join([x.upper() if i % 2 else x for i, x in enumerate(split_str)])
New contributor
boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
up vote
0
down vote
Those don't look like real xml tags. But assuming the number of <big>
tags are used correctly, you can split it by tag and apply upper()
to strings between.
text = "<big>t<big>his should be <big>u<big>ppercase"
split_str = text.split('<big>')
result = ''.join([x.upper() if i % 2 else x for i, x in enumerate(split_str)])
New contributor
boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Those don't look like real xml tags. But assuming the number of <big>
tags are used correctly, you can split it by tag and apply upper()
to strings between.
text = "<big>t<big>his should be <big>u<big>ppercase"
split_str = text.split('<big>')
result = ''.join([x.upper() if i % 2 else x for i, x in enumerate(split_str)])
New contributor
boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered yesterday
boonwj
1114
1114
New contributor
boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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%2fstackoverflow.com%2fquestions%2f53238506%2fmake-character-in-tag-uppercase-and-remove-tag%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
Post as a guest
0z3Nj,f g,vnM,DGoLcce1,HJKjBQN6b,y1t vgqKuOLMI1
1
I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable name
str
is reserved!!– Anton vBR
yesterday
is <big> even a real tag?
– Paritosh Singh
yesterday
It's not a real tag, just for example.
– rw026
yesterday
Normally you'd expect the closing tag to be
</big>
– khelwood
yesterday
Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
– Paritosh Singh
yesterday