On Tue, Oct 14, 2014 at 9:28 AM, David Lang <[email protected]> wrote:
> On Tue, 14 Oct 2014, singh.janmejay wrote:
>
> Yep, makes sense.
>>
>> I'll make the change.
>>
>> Im thinking:
>>
>> wrap(operand, string_to_wrap_around_it, boolean_ignore_if_already_
>> present)
>>
>> escape(operand, string_to_find, string_to_escape_it_with)
>>
>> Does this capture the essence?
>>
>
> Your escape function is identical to the replace function. What do you do
> if the boolean is false? (i.e. don't ignore if already present)
>
Yes, escape was same as replace, my bad.
>
> I was thinking something like:
>
> wrap(operand, string_to_wrap_around_it, string_to_escape_it_with)
>
This is still achievable by use of replace followed by wrap(the way they
are).
Something that you mentioned in the first reply (don't wrap if the fragment
is already present) is still not possible.
That is what I was trying to solve for with ignore-boolean.
Eg.
wrap("foo", "_", true) => "_foo_"
wrap("_foo", "_", true) => "__foo_"
wrap("_foo", "_", false) => "_foo_"
The third param here is the ignore_if_already_present boolean.
>
> if string_to_escape_it_with is not null, replace any occurances of the
> wrap string in the middle with the escape string.
>
> If the third parameter is not provided or is null, don't look for anything
> in the middle.
>
> David Lang
>
>
>
>> On Tue, Oct 14, 2014 at 8:02 AM, David Lang <[email protected]> wrote:
>>
>> As a thought, for wrap, I would suggest adding an optional third
>>> parameter, namely what to use if the string_to_wrap_around_it already
>>> appears in the string. I'm thinking along the lines of quoting a string
>>> and
>>> dealing with quotes in the middle of it, but any time you put delimeters
>>> around a string, there is a really good chance that you don't want that
>>> string to appear in the middle of it (unless the wrapping is purely for
>>> human consumption)
>>>
>>> David Lang
>>>
>>>
>>>
>>> On Mon, 13 Oct 2014, singh.janmejay wrote:
>>>
>>> Hi,
>>>
>>>>
>>>> Have added 3 functions to rainerscript:
>>>> - replace(operand, substring_to_be_replaced, its_replacement)
>>>> - wrap(operand, string_to_wrap_around_it)
>>>> - concat(operand_1, operand_2)
>>>>
>>>> Examples:
>>>> replace("foo bar baz", "ba", "BA") => "foo BAr BAz"
>>>> concat("foo", "bar") => "foobar"
>>>> wrap("hello", "__") => "__hello__"
>>>> replace("foo bar", concat("b", "ar"), wrap("baz", "*")) => "foo *baz*"
>>>>
>>>> I felt the need for this while working on some unstructured ->
>>>> structured
>>>> transformation of log-messages. Searched the forums a little, for
>>>> instance:
>>>> http://kb.monitorware.com/modify-message-string-strip-
>>>> addresses-from-logs-t1610.html
>>>> and found that nothing equivalent existed, hence the patch.
>>>>
>>>> 0001-... has replace and wrap impl
>>>> 0002-... has concat impl
>>>> (the patches go in the same order)
>>>>
>>>> Im currently running an large installation with these patches applied
>>>> over
>>>> 8.4.0, they seem to be working fine.
>>>>
>>>> If the patches look good for merging, I'll be happy to update the
>>>> documentation(actually don't know how to update doc yet, will have to
>>>> dig
>>>> in to learn more about it).
>>>>
>>>>
>>>> _______________________________________________
>>> rsyslog mailing list
>>> http://lists.adiscon.net/mailman/listinfo/rsyslog
>>> http://www.rsyslog.com/professional-services/
>>> What's up with rsyslog? Follow https://twitter.com/rgerhards
>>> NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad
>>> of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you
>>> DON'T LIKE THAT.
>>> _______________________________________________
>>> rsyslog mailing list
>>> http://lists.adiscon.net/mailman/listinfo/rsyslog
>>> http://www.rsyslog.com/professional-services/
>>> What's up with rsyslog? Follow https://twitter.com/rgerhards
>>> NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad
>>> of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you
>>> DON'T LIKE THAT.
>>>
>>>
>>
>>
>>
>> _______________________________________________
> rsyslog mailing list
> http://lists.adiscon.net/mailman/listinfo/rsyslog
> http://www.rsyslog.com/professional-services/
> What's up with rsyslog? Follow https://twitter.com/rgerhards
> NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad
> of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you
> DON'T LIKE THAT.
>
--
Regards,
Janmejay
http://codehunk.wordpress.com
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE
THAT.