polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stanislav Muhametsin <stanislav.muhamet...@zest.mail.kapsi.fi>
Subject Re: Why I don't like regular expressions...
Date Wed, 05 Jul 2017 08:14:37 GMT
My ancient code, I think.
Probably a brain fart, or some "preliminary version here and I fix it 
later" and 'later' never happened. :D
Too many years has passed to remember the actual reason.

But yeah, it is definetly not working for multiple types...
The last group should be probably:

{([^},]+)(,[^},]+)*}


On 05/07/2017 10:26, Niclas Hedhman wrote:
> We have
>
> private static final Pattern DESCRIPTOR_TEXTUAL_REGEXP = Pattern.compile(
>      "^"
>      + Pattern.quote( DESCRIPTOR_COMPONENT_SEPARATOR_START ) + "(.*)"
>      + Pattern.quote( DESCRIPTOR_COMPONENT_SEPARATOR_END )
>      + Pattern.quote( DESCRIPTOR_COMPONENT_SEPARATOR_START ) + "(.*)"
>      + Pattern.quote( DESCRIPTOR_COMPONENT_SEPARATOR_END )
>      + Pattern.quote( DESCRIPTOR_COMPONENT_SEPARATOR_START ) + "(" + "[^"
>      + Pattern.quote( DESCRIPTOR_COMPONENT_SEPARATOR_END +
> DESCRIPTOR_TYPE_SEPARATOR )
>      + "]+)" + Pattern.quote( DESCRIPTOR_COMPONENT_SEPARATOR_END ) + "$" );
>
>
> in org.apache.polygene.index.sql.support.skeletons.AbstractSQLStartup
>
> And in method stringToCompositeDescriptor()
>
> Matcher matcher = DESCRIPTOR_TEXTUAL_REGEXP.matcher( str );
> if( !matcher.matches() )
> {
>      throw new IllegalArgumentException( "Descriptor textual description " + str
>                                          + " was invalid." );
> }
>
> and of course it says that it doesn't match with
>
> {Domain Layer}{Organization Module}{interface
> com.sensetif.sink.model.organization.CreditLimit,interface
> org.apache.polygene.api.value.ValueComposite}
>
>
> so where is the problem?
>
>
> The RegExp "Pattern" prints out to
>
> ^\Q{\E(.*)\Q}\E\Q{\E(.*)\Q}\E\Q{\E([^\Q},\E]+)\Q}\E$
>
> as if that helps...
>
> So I realize that the \Q and \E are escaping markers, so it is basically
> saying
>
> ^{(.*)}{(.*)}{([^},]+)}$
>
> (where comma and curlies being ordinary characters)
>
> But the third group shouldn't work at all...
>
> * ([^},]+)*
>
> So, that is a group of one or more characters but not comma and not end
> brace...
>
>
> Has this ever worked? Because a few lines later, the sequence of types are
> being extracted, so it was intended to have multiple types.
>
>
> I am at loss.
>
>
> Cheers


Mime
View raw message