Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How do i use perl for replacing capture group content (updated)

by haukex (Archbishop)
on Jul 08, 2019 at 13:23 UTC ( [id://11102552]=note: print w/replies, xml ) Need Help??


in reply to How do i use perl for replacing capture group content

code isn`t working it changes all the indexes to linux instead of linux_pr (or linux_np)
perl -00pe 's#^\[monitor:///var/log/(?:messages|secure|cron|maillog|sp +ooler|audit/audit\.log)\]\n.*^index\s*=\s*\k.+(?=_(?:np|pr)\s*$)#linu +x#ms' inputs.conf _DATA_ [monitor:///var/log/cron] index=NDNW_np sourcetype=syslog ...

That's not the behavior I'm seeing. I'm getting the error message "Sequence \k... not terminated in regex", and if you correct \k to \K, the code works fine for me. Please take care that when you post questions, they are as accurate as possible. Please read How do I post a question effectively?, SSCCE, and I know what I mean. Why don't you?

Update: It appears you've edited your previous question from yesterday, Regex for replacing capture group content using perl, to add this question there as well. Please don't do this, making a new post is enough - in this case a reply in the previous thread would probably have been best, so that the question has more context. And I already pointed you to How do I change/delete my post? and "It is uncool to update a node in a way that renders replies confusing or meaningless".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11102552]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-25 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found