Regex to find named XML tags which may be emptyRegEx match open tags except XHTML self-contained tagsRegEx match open tags except XHTML self-contained tagsFind and kill a process in one line using bash and regexRemove all empty HTML tags?Regex: How to capture this? (a nested group inside a repeated group)Regex to Find and Replace Text NOT in a TagHow to clean up XML attributes using regex?Combining two regex functions to strip html tagsRegular expression for replacing extra characters between markersregex just only match first substringRegex to find non-alphanumeric symbols wrapped into certain XML tags
What's the easiest way for a whole party to be able to communicate with a creature that doesn't know Common?
In native German words, is Q always followed by U, as in English?
What game is this character in the Pixels movie from?
How did Lefschetz do mathematics without hands?
Ordered list of OR journals
Should I share with a new service provider a bill from its competitor?
Is it legal to call shared_future::get() multiple times on the same instance in the same thread?
Perl 6 multi methods never match expected signature
Was it really unprofessional of me to leave without asking for a raise first?
Why do we use a cylinder as a Gaussian surface for infinitely long charged wire?
Symbol for "not absolutely continuous" in Latex
Prime parity peregrination
Can Aziraphale and Crowley actually become native?
How hard is it to sell a home which is currently mortgaged?
Why do changes to /etc/hosts take effect immediately?
Could a Weapon of Mass Destruction, targeting only humans, be developed?
What drives vibrational cooling in an excited stated?
Boolean Difference with Offset?
Different budgets within roommate group
Why do I need two parameters in an HTTP parameter pollution attack?
Is it bad to describe a character long after their introduction?
Most important new papers in computational complexity
Donkey as Democratic Party symbolic animal
Why is Japan trying to have a better relationship with Iran?
Regex to find named XML tags which may be empty
RegEx match open tags except XHTML self-contained tagsRegEx match open tags except XHTML self-contained tagsFind and kill a process in one line using bash and regexRemove all empty HTML tags?Regex: How to capture this? (a nested group inside a repeated group)Regex to Find and Replace Text NOT in a TagHow to clean up XML attributes using regex?Combining two regex functions to strip html tagsRegular expression for replacing extra characters between markersregex just only match first substringRegex to find non-alphanumeric symbols wrapped into certain XML tags
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have problem to find specific named xml tags within a text block which may or may not be empty. I am not sure if the problem is after all resolvable with regex.
For example I have the following text block:
...<item name="xxx">yyyy</item>....
To filter out the 'item' tag with its attributes I a use the following regex:
<item(.*?)>(.*?)</item>|<item(.*?)./>
This regex also works with empty tags like in the following example text:
...<item name="zzz" />....
My problem is that my text contains multiple 'item' tags. This works as long as I do not mix the empty with not-empty tags like in the following example textblock:
...<item name="zzz" />....
...<item name="xxx">yyyy</item>....
The regex I use did not work with this siutation as it finds the first result:
<item name="zzz" />.......<item name="xxx">yyyy</item>
My question is: Is this problem solveable with regex?
My first thougt was to use kind of "AND NOT" combination like
(<item(.*?))(?!/>)>(.*?)</item>
But I failed at the problem.
My Java Code to apply the regex to a given textblock looks like this:
Pattern pattern = Pattern.compile("<item(.*?)>(.*?)</item>|<item(.*?)./>", Pattern.DOTALL);
Matcher matcher = pattern.matcher(textblock);
while (matcher.find())
String attributes = matcher.group(1);
....
regex
add a comment |
I have problem to find specific named xml tags within a text block which may or may not be empty. I am not sure if the problem is after all resolvable with regex.
For example I have the following text block:
...<item name="xxx">yyyy</item>....
To filter out the 'item' tag with its attributes I a use the following regex:
<item(.*?)>(.*?)</item>|<item(.*?)./>
This regex also works with empty tags like in the following example text:
...<item name="zzz" />....
My problem is that my text contains multiple 'item' tags. This works as long as I do not mix the empty with not-empty tags like in the following example textblock:
...<item name="zzz" />....
...<item name="xxx">yyyy</item>....
The regex I use did not work with this siutation as it finds the first result:
<item name="zzz" />.......<item name="xxx">yyyy</item>
My question is: Is this problem solveable with regex?
My first thougt was to use kind of "AND NOT" combination like
(<item(.*?))(?!/>)>(.*?)</item>
But I failed at the problem.
My Java Code to apply the regex to a given textblock looks like this:
Pattern pattern = Pattern.compile("<item(.*?)>(.*?)</item>|<item(.*?)./>", Pattern.DOTALL);
Matcher matcher = pattern.matcher(textblock);
while (matcher.find())
String attributes = matcher.group(1);
....
regex
5
Is there a reason you can't use an XML parser? Note that parsing XML/HTML using regex is generally not a good idea.
– Ahmed Abdelhameed
Mar 25 at 13:25
Thanks for your answer - ok I almost guessed that this cannot be resolved sensibly with a Regex.
– Ralph
Mar 25 at 13:48
add a comment |
I have problem to find specific named xml tags within a text block which may or may not be empty. I am not sure if the problem is after all resolvable with regex.
For example I have the following text block:
...<item name="xxx">yyyy</item>....
To filter out the 'item' tag with its attributes I a use the following regex:
<item(.*?)>(.*?)</item>|<item(.*?)./>
This regex also works with empty tags like in the following example text:
...<item name="zzz" />....
My problem is that my text contains multiple 'item' tags. This works as long as I do not mix the empty with not-empty tags like in the following example textblock:
...<item name="zzz" />....
...<item name="xxx">yyyy</item>....
The regex I use did not work with this siutation as it finds the first result:
<item name="zzz" />.......<item name="xxx">yyyy</item>
My question is: Is this problem solveable with regex?
My first thougt was to use kind of "AND NOT" combination like
(<item(.*?))(?!/>)>(.*?)</item>
But I failed at the problem.
My Java Code to apply the regex to a given textblock looks like this:
Pattern pattern = Pattern.compile("<item(.*?)>(.*?)</item>|<item(.*?)./>", Pattern.DOTALL);
Matcher matcher = pattern.matcher(textblock);
while (matcher.find())
String attributes = matcher.group(1);
....
regex
I have problem to find specific named xml tags within a text block which may or may not be empty. I am not sure if the problem is after all resolvable with regex.
For example I have the following text block:
...<item name="xxx">yyyy</item>....
To filter out the 'item' tag with its attributes I a use the following regex:
<item(.*?)>(.*?)</item>|<item(.*?)./>
This regex also works with empty tags like in the following example text:
...<item name="zzz" />....
My problem is that my text contains multiple 'item' tags. This works as long as I do not mix the empty with not-empty tags like in the following example textblock:
...<item name="zzz" />....
...<item name="xxx">yyyy</item>....
The regex I use did not work with this siutation as it finds the first result:
<item name="zzz" />.......<item name="xxx">yyyy</item>
My question is: Is this problem solveable with regex?
My first thougt was to use kind of "AND NOT" combination like
(<item(.*?))(?!/>)>(.*?)</item>
But I failed at the problem.
My Java Code to apply the regex to a given textblock looks like this:
Pattern pattern = Pattern.compile("<item(.*?)>(.*?)</item>|<item(.*?)./>", Pattern.DOTALL);
Matcher matcher = pattern.matcher(textblock);
while (matcher.find())
String attributes = matcher.group(1);
....
regex
regex
edited Mar 25 at 17:33
Ralph
asked Mar 25 at 13:22
RalphRalph
1,4004 gold badges28 silver badges46 bronze badges
1,4004 gold badges28 silver badges46 bronze badges
5
Is there a reason you can't use an XML parser? Note that parsing XML/HTML using regex is generally not a good idea.
– Ahmed Abdelhameed
Mar 25 at 13:25
Thanks for your answer - ok I almost guessed that this cannot be resolved sensibly with a Regex.
– Ralph
Mar 25 at 13:48
add a comment |
5
Is there a reason you can't use an XML parser? Note that parsing XML/HTML using regex is generally not a good idea.
– Ahmed Abdelhameed
Mar 25 at 13:25
Thanks for your answer - ok I almost guessed that this cannot be resolved sensibly with a Regex.
– Ralph
Mar 25 at 13:48
5
5
Is there a reason you can't use an XML parser? Note that parsing XML/HTML using regex is generally not a good idea.
– Ahmed Abdelhameed
Mar 25 at 13:25
Is there a reason you can't use an XML parser? Note that parsing XML/HTML using regex is generally not a good idea.
– Ahmed Abdelhameed
Mar 25 at 13:25
Thanks for your answer - ok I almost guessed that this cannot be resolved sensibly with a Regex.
– Ralph
Mar 25 at 13:48
Thanks for your answer - ok I almost guessed that this cannot be resolved sensibly with a Regex.
– Ralph
Mar 25 at 13:48
add a comment |
1 Answer
1
active
oldest
votes
Your regex will work if using tag attributes regex as defined by the w3c
you can get 100% accuracy in finding open and self-contained tags.
But, you need an engine that uses atomic groups you can also differentiate
between open and self contained as below:
Raw:
(?s)(?:(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</items*>))
Double quoted:
"(?s)(?:(<item(?>\b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>\b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</item\s*>))"
https://regex101.com/r/R3iVVW/1
(?s)
(?:
( # (1 start), Self Contained item
<item
(?> # Atomic to trap self contained
b
(?: " .*? " | ' .*? ' | [^>]*? )*
>
)
(?<= /> ) # Must be a self contained item
) # (1 end)
| # OR,
( # (2 start), Open item
<item
(?> # Atomic to trap self contained
b
(?: " .*? " | ' .*? ' | [^>]*? )*
>
)
(?<! /> ) # Not a self contained item
) # (2 end)
( .*? ) # (3), Item content
( </item s* > ) # (4), Close item
)
Benchmarked:
Regex1: (?s)(?:(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</items*>))
Options: < none >
Completed iterations: 50 / 50 ( x 1000 )
Matches found per iteration: 14
Elapsed Time: 4.73 s, 4728.21 ms, 4728214 µs
Matches per sec: 148,047
Thanks for your solution. The problem is that the order of the item tags can change.
– Ralph
Mar 25 at 17:19
The problem seems to be in java only. Your first example works fine on regex101.com. But it does not work in Java using a java.util.regex.Matcher. So I change my code by simply parsing the content manually. I compile the pattern in java using the Pattern.DOTALL option.
– Ralph
Mar 25 at 17:28
@Ralph - Ok, made the adjustment, this works with both types, try it out ...
– sln
Mar 25 at 17:50
1
Thanks a lot. This regex is impressive! and it works in all my scenarios (I have a lot of junit tests)
– Ralph
Mar 26 at 9:34
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55338799%2fregex-to-find-named-xml-tags-which-may-be-empty%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your regex will work if using tag attributes regex as defined by the w3c
you can get 100% accuracy in finding open and self-contained tags.
But, you need an engine that uses atomic groups you can also differentiate
between open and self contained as below:
Raw:
(?s)(?:(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</items*>))
Double quoted:
"(?s)(?:(<item(?>\b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>\b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</item\s*>))"
https://regex101.com/r/R3iVVW/1
(?s)
(?:
( # (1 start), Self Contained item
<item
(?> # Atomic to trap self contained
b
(?: " .*? " | ' .*? ' | [^>]*? )*
>
)
(?<= /> ) # Must be a self contained item
) # (1 end)
| # OR,
( # (2 start), Open item
<item
(?> # Atomic to trap self contained
b
(?: " .*? " | ' .*? ' | [^>]*? )*
>
)
(?<! /> ) # Not a self contained item
) # (2 end)
( .*? ) # (3), Item content
( </item s* > ) # (4), Close item
)
Benchmarked:
Regex1: (?s)(?:(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</items*>))
Options: < none >
Completed iterations: 50 / 50 ( x 1000 )
Matches found per iteration: 14
Elapsed Time: 4.73 s, 4728.21 ms, 4728214 µs
Matches per sec: 148,047
Thanks for your solution. The problem is that the order of the item tags can change.
– Ralph
Mar 25 at 17:19
The problem seems to be in java only. Your first example works fine on regex101.com. But it does not work in Java using a java.util.regex.Matcher. So I change my code by simply parsing the content manually. I compile the pattern in java using the Pattern.DOTALL option.
– Ralph
Mar 25 at 17:28
@Ralph - Ok, made the adjustment, this works with both types, try it out ...
– sln
Mar 25 at 17:50
1
Thanks a lot. This regex is impressive! and it works in all my scenarios (I have a lot of junit tests)
– Ralph
Mar 26 at 9:34
add a comment |
Your regex will work if using tag attributes regex as defined by the w3c
you can get 100% accuracy in finding open and self-contained tags.
But, you need an engine that uses atomic groups you can also differentiate
between open and self contained as below:
Raw:
(?s)(?:(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</items*>))
Double quoted:
"(?s)(?:(<item(?>\b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>\b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</item\s*>))"
https://regex101.com/r/R3iVVW/1
(?s)
(?:
( # (1 start), Self Contained item
<item
(?> # Atomic to trap self contained
b
(?: " .*? " | ' .*? ' | [^>]*? )*
>
)
(?<= /> ) # Must be a self contained item
) # (1 end)
| # OR,
( # (2 start), Open item
<item
(?> # Atomic to trap self contained
b
(?: " .*? " | ' .*? ' | [^>]*? )*
>
)
(?<! /> ) # Not a self contained item
) # (2 end)
( .*? ) # (3), Item content
( </item s* > ) # (4), Close item
)
Benchmarked:
Regex1: (?s)(?:(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</items*>))
Options: < none >
Completed iterations: 50 / 50 ( x 1000 )
Matches found per iteration: 14
Elapsed Time: 4.73 s, 4728.21 ms, 4728214 µs
Matches per sec: 148,047
Thanks for your solution. The problem is that the order of the item tags can change.
– Ralph
Mar 25 at 17:19
The problem seems to be in java only. Your first example works fine on regex101.com. But it does not work in Java using a java.util.regex.Matcher. So I change my code by simply parsing the content manually. I compile the pattern in java using the Pattern.DOTALL option.
– Ralph
Mar 25 at 17:28
@Ralph - Ok, made the adjustment, this works with both types, try it out ...
– sln
Mar 25 at 17:50
1
Thanks a lot. This regex is impressive! and it works in all my scenarios (I have a lot of junit tests)
– Ralph
Mar 26 at 9:34
add a comment |
Your regex will work if using tag attributes regex as defined by the w3c
you can get 100% accuracy in finding open and self-contained tags.
But, you need an engine that uses atomic groups you can also differentiate
between open and self contained as below:
Raw:
(?s)(?:(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</items*>))
Double quoted:
"(?s)(?:(<item(?>\b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>\b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</item\s*>))"
https://regex101.com/r/R3iVVW/1
(?s)
(?:
( # (1 start), Self Contained item
<item
(?> # Atomic to trap self contained
b
(?: " .*? " | ' .*? ' | [^>]*? )*
>
)
(?<= /> ) # Must be a self contained item
) # (1 end)
| # OR,
( # (2 start), Open item
<item
(?> # Atomic to trap self contained
b
(?: " .*? " | ' .*? ' | [^>]*? )*
>
)
(?<! /> ) # Not a self contained item
) # (2 end)
( .*? ) # (3), Item content
( </item s* > ) # (4), Close item
)
Benchmarked:
Regex1: (?s)(?:(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</items*>))
Options: < none >
Completed iterations: 50 / 50 ( x 1000 )
Matches found per iteration: 14
Elapsed Time: 4.73 s, 4728.21 ms, 4728214 µs
Matches per sec: 148,047
Your regex will work if using tag attributes regex as defined by the w3c
you can get 100% accuracy in finding open and self-contained tags.
But, you need an engine that uses atomic groups you can also differentiate
between open and self contained as below:
Raw:
(?s)(?:(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</items*>))
Double quoted:
"(?s)(?:(<item(?>\b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>\b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</item\s*>))"
https://regex101.com/r/R3iVVW/1
(?s)
(?:
( # (1 start), Self Contained item
<item
(?> # Atomic to trap self contained
b
(?: " .*? " | ' .*? ' | [^>]*? )*
>
)
(?<= /> ) # Must be a self contained item
) # (1 end)
| # OR,
( # (2 start), Open item
<item
(?> # Atomic to trap self contained
b
(?: " .*? " | ' .*? ' | [^>]*? )*
>
)
(?<! /> ) # Not a self contained item
) # (2 end)
( .*? ) # (3), Item content
( </item s* > ) # (4), Close item
)
Benchmarked:
Regex1: (?s)(?:(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<=/>))|(<item(?>b(?:".*?"|'.*?'|[^>]*?)*>)(?<!/>))(.*?)(</items*>))
Options: < none >
Completed iterations: 50 / 50 ( x 1000 )
Matches found per iteration: 14
Elapsed Time: 4.73 s, 4728.21 ms, 4728214 µs
Matches per sec: 148,047
edited Mar 25 at 17:56
answered Mar 25 at 17:10
slnsln
29.3k3 gold badges16 silver badges39 bronze badges
29.3k3 gold badges16 silver badges39 bronze badges
Thanks for your solution. The problem is that the order of the item tags can change.
– Ralph
Mar 25 at 17:19
The problem seems to be in java only. Your first example works fine on regex101.com. But it does not work in Java using a java.util.regex.Matcher. So I change my code by simply parsing the content manually. I compile the pattern in java using the Pattern.DOTALL option.
– Ralph
Mar 25 at 17:28
@Ralph - Ok, made the adjustment, this works with both types, try it out ...
– sln
Mar 25 at 17:50
1
Thanks a lot. This regex is impressive! and it works in all my scenarios (I have a lot of junit tests)
– Ralph
Mar 26 at 9:34
add a comment |
Thanks for your solution. The problem is that the order of the item tags can change.
– Ralph
Mar 25 at 17:19
The problem seems to be in java only. Your first example works fine on regex101.com. But it does not work in Java using a java.util.regex.Matcher. So I change my code by simply parsing the content manually. I compile the pattern in java using the Pattern.DOTALL option.
– Ralph
Mar 25 at 17:28
@Ralph - Ok, made the adjustment, this works with both types, try it out ...
– sln
Mar 25 at 17:50
1
Thanks a lot. This regex is impressive! and it works in all my scenarios (I have a lot of junit tests)
– Ralph
Mar 26 at 9:34
Thanks for your solution. The problem is that the order of the item tags can change.
– Ralph
Mar 25 at 17:19
Thanks for your solution. The problem is that the order of the item tags can change.
– Ralph
Mar 25 at 17:19
The problem seems to be in java only. Your first example works fine on regex101.com. But it does not work in Java using a java.util.regex.Matcher. So I change my code by simply parsing the content manually. I compile the pattern in java using the Pattern.DOTALL option.
– Ralph
Mar 25 at 17:28
The problem seems to be in java only. Your first example works fine on regex101.com. But it does not work in Java using a java.util.regex.Matcher. So I change my code by simply parsing the content manually. I compile the pattern in java using the Pattern.DOTALL option.
– Ralph
Mar 25 at 17:28
@Ralph - Ok, made the adjustment, this works with both types, try it out ...
– sln
Mar 25 at 17:50
@Ralph - Ok, made the adjustment, this works with both types, try it out ...
– sln
Mar 25 at 17:50
1
1
Thanks a lot. This regex is impressive! and it works in all my scenarios (I have a lot of junit tests)
– Ralph
Mar 26 at 9:34
Thanks a lot. This regex is impressive! and it works in all my scenarios (I have a lot of junit tests)
– Ralph
Mar 26 at 9:34
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55338799%2fregex-to-find-named-xml-tags-which-may-be-empty%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
Is there a reason you can't use an XML parser? Note that parsing XML/HTML using regex is generally not a good idea.
– Ahmed Abdelhameed
Mar 25 at 13:25
Thanks for your answer - ok I almost guessed that this cannot be resolved sensibly with a Regex.
– Ralph
Mar 25 at 13:48