You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by James Watkin <ja...@anderson.ucla.edu> on 2007/09/10 04:45:38 UTC
[StrSubstitutor] Can StrSubstitutor be used without a prefix or suffix?
I'd like to use org.apache.commons.lang.text.StrSubstitutor without a
suffix requirement for the replacement targets, but it doesn't seem to
support that. Is that correct?
Although the doc for org.apache.commons.lang.text.StrSubstitutor
disallows a null prefix or suffix in the constructor, it doesn't mention
the empty string. I tried the empty string for the prefix and suffix but
that didn't work.
- Jim
______________________________
James Watkin
ACIS Software Development
UCLA Anderson School
james.watkin@anderson.ucla.edu
Voice: 1-310-825-5030
Fax: 1-310-825-4835
______________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [StrSubstitutor] Can StrSubstitutor be used without a prefix
or suffix?
Posted by James Watkin <ja...@anderson.ucla.edu>.
To be clear, I meant that I wrote my own search & replace code, not
using StrSubstitutor.
Even if it were possible to do something with StrMatcher, as a future
enhancement, it might be nice if it could also be done by setting the
prefix and suffix to "" directly from the StrSubstitutor API.
- Jim
James Watkin wrote:
> Oliver,
>
> Thanks for the advice. I had briefly looked at that and didn't see an
> obvious "match anything" StrMatcher so I opted to write my own code.
> Depending on formating, it's only around ten lines of code.
>
> - Jim
>
> Oliver Heger wrote:
>> James Watkin wrote:
>>> I'd like to use org.apache.commons.lang.text.StrSubstitutor without a
>>> suffix requirement for the replacement targets, but it doesn't seem
>>> to support that. Is that correct?
>>>
>>> Although the doc for org.apache.commons.lang.text.StrSubstitutor
>>> disallows a null prefix or suffix in the constructor, it doesn't
>>> mention the empty string. I tried the empty string for the prefix and
>>> suffix but that didn't work.
>>>
>>> - Jim
>>
>> By looking at the code, yes, it seems that a suffix is required.
>>
>> How do the variables look like you are dealing with? Perhaps it is an
>> option to provide your own implementation of the StrMatcher class [1],
>> which is internally used for detecting prefixes and suffixes
>> (StrSubstitutor has methods that take such matchers instead of a
>> prefix and a suffix as string). This should not be too complicated.
>>
>> HTH
>> Oliver
>>
>> [1]
>> http://commons.apache.org/lang/api-release/org/apache/commons/lang/text/StrMatcher.html
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
--
______________________________
James Watkin
ACIS Software Development
UCLA Anderson School
james.watkin@anderson.ucla.edu
Voice: 1-310-825-5030
Fax: 1-310-825-4835
______________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [StrSubstitutor] Can StrSubstitutor be used without a prefix
or suffix?
Posted by James Watkin <ja...@anderson.ucla.edu>.
Oliver,
Thanks for the advice. I had briefly looked at that and didn't see an
obvious "match anything" StrMatcher so I opted to write my own code.
Depending on formating, it's only around ten lines of code.
- Jim
Oliver Heger wrote:
> James Watkin wrote:
>> I'd like to use org.apache.commons.lang.text.StrSubstitutor without a
>> suffix requirement for the replacement targets, but it doesn't seem to
>> support that. Is that correct?
>>
>> Although the doc for org.apache.commons.lang.text.StrSubstitutor
>> disallows a null prefix or suffix in the constructor, it doesn't
>> mention the empty string. I tried the empty string for the prefix and
>> suffix but that didn't work.
>>
>> - Jim
>
> By looking at the code, yes, it seems that a suffix is required.
>
> How do the variables look like you are dealing with? Perhaps it is an
> option to provide your own implementation of the StrMatcher class [1],
> which is internally used for detecting prefixes and suffixes
> (StrSubstitutor has methods that take such matchers instead of a prefix
> and a suffix as string). This should not be too complicated.
>
> HTH
> Oliver
>
> [1]
> http://commons.apache.org/lang/api-release/org/apache/commons/lang/text/StrMatcher.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
--
______________________________
James Watkin
ACIS Software Development
UCLA Anderson School
james.watkin@anderson.ucla.edu
Voice: 1-310-825-5030
Fax: 1-310-825-4835
______________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [StrSubstitutor] Can StrSubstitutor be used without a prefix
or suffix?
Posted by Oliver Heger <ol...@oliver-heger.de>.
James Watkin wrote:
> I'd like to use org.apache.commons.lang.text.StrSubstitutor without a
> suffix requirement for the replacement targets, but it doesn't seem to
> support that. Is that correct?
>
> Although the doc for org.apache.commons.lang.text.StrSubstitutor
> disallows a null prefix or suffix in the constructor, it doesn't mention
> the empty string. I tried the empty string for the prefix and suffix but
> that didn't work.
>
> - Jim
By looking at the code, yes, it seems that a suffix is required.
How do the variables look like you are dealing with? Perhaps it is an
option to provide your own implementation of the StrMatcher class [1],
which is internally used for detecting prefixes and suffixes
(StrSubstitutor has methods that take such matchers instead of a prefix
and a suffix as string). This should not be too complicated.
HTH
Oliver
[1]
http://commons.apache.org/lang/api-release/org/apache/commons/lang/text/StrMatcher.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org