<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Regular Expression: Invalid Statement cause of quantifier ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/regular-expression-invalid-statement-cause-of-quantifier/m-p/4633189#M1091031</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to build a regular expression to find all namespaces in a xml document (&amp;lt;root xmlns:test="blah" xmlns="blubb"&amp;gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My regex looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;((xmlns:.*?=".*?")|(xmlns=".*?"))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For some strange reason, the compliler thinks, this statement is invalid. I tested it with different external regex parsers, and it worked perfectly and returned the list of namespaces.&lt;/P&gt;&lt;P&gt;The compiler message says, that there is an error at the position "11" which points to the "?". Removing all ? in the statement, compiling works, but then the result is wrong &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FIND REGEX '((xmlns:.*?=".*?")|(xmlns=".*?"))' IN lv_xml_in
     RESULTS lt_result.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have an idea what the issue is?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanx,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sascha&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update: I found the following statement in the Help: *? - Reserved for later enhancements. Which means, that the switch for relaxed behaviour is not working (yet). Do you have an idea, how to restate the expression, to meet my requirement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Sascha Kiefer on Oct 27, 2008 6:31 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Oct 2008 16:08:49 GMT</pubDate>
    <dc:creator>sascha_kiefer</dc:creator>
    <dc:date>2008-10-27T16:08:49Z</dc:date>
    <item>
      <title>Regular Expression: Invalid Statement cause of quantifier ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regular-expression-invalid-statement-cause-of-quantifier/m-p/4633189#M1091031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to build a regular expression to find all namespaces in a xml document (&amp;lt;root xmlns:test="blah" xmlns="blubb"&amp;gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My regex looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;((xmlns:.*?=".*?")|(xmlns=".*?"))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For some strange reason, the compliler thinks, this statement is invalid. I tested it with different external regex parsers, and it worked perfectly and returned the list of namespaces.&lt;/P&gt;&lt;P&gt;The compiler message says, that there is an error at the position "11" which points to the "?". Removing all ? in the statement, compiling works, but then the result is wrong &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FIND REGEX '((xmlns:.*?=".*?")|(xmlns=".*?"))' IN lv_xml_in
     RESULTS lt_result.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have an idea what the issue is?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanx,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sascha&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update: I found the following statement in the Help: *? - Reserved for later enhancements. Which means, that the switch for relaxed behaviour is not working (yet). Do you have an idea, how to restate the expression, to meet my requirement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Sascha Kiefer on Oct 27, 2008 6:31 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Oct 2008 16:08:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regular-expression-invalid-statement-cause-of-quantifier/m-p/4633189#M1091031</guid>
      <dc:creator>sascha_kiefer</dc:creator>
      <dc:date>2008-10-27T16:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression: Invalid Statement cause of quantifier ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regular-expression-invalid-statement-cause-of-quantifier/m-p/4633190#M1091032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as long as the "relaxed behavior" of RegEx is not supported in the kernel, I use the following work-around:&lt;/P&gt;&lt;P&gt;I look for the first occurence, store it, and remove it from the XML input string (which works perfectly for me, since I want to remove it anyway. If you just want to extract it, I guess you have to use a copy of the original string). I repeat the search and replace until no mor matches are found.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's to coding:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: ls_result    TYPE match_result,
      lv_namespace TYPE string,
      lt_namespace TYPE TABLE OF string.

WHILE 1 = 1.
  CLEAR: ls_result,
         lv_namespace.

  FIND FIRST OCCURRENCE OF REGEX '(xmlns:.[^=]*="[^"]*")|(xmlns="[^"]*")'
    IN lv_xml_in
    IGNORING CASE
    RESULTS ls_result.

  IF sy-subrc NE 0.
    EXIT.
  ENDIF.

  lv_namespace = lv_xml_in+ls_result-offset(ls_result-length).
  APPEND lv_namespace TO lt_namespace.

  REPLACE FIRST OCCURRENCE OF lv_namespace IN lv_xml_in WITH ''.
ENDWHILE.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Oct 2008 10:43:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regular-expression-invalid-statement-cause-of-quantifier/m-p/4633190#M1091032</guid>
      <dc:creator>sascha_kiefer</dc:creator>
      <dc:date>2008-10-28T10:43:20Z</dc:date>
    </item>
  </channel>
</rss>

