I've got a big file with a regex filter. I'm converting it from a system to another, but it needs some modification.
Right now it looks like this:
{
"chatpattern" "MY REGEX FILTER"
}
But first I want to add a line inbetween the {
and the chatpattern
by doing the following in the search and replace function:
search: {
replace: { \r "TEXT" \r
And here comes the problem, after the first line I want the "TEXT"
to increment by 1, so it'll be like:
{
"TEXT1"
"chatpattern" "MY REGEX FILTER"
}
{
"TEXT2"
"chatpattern" "MY REGEX FILTER"
}
{
"TEXT3"
"chatpattern" "MY REGEX FILTER"
}
Is this possible?
Here is a perl oneliner that does the job:
perl -pi.back -e 's/\{/"{\ntext".++$i/e;' in.txt
The substitution is done in place.>br> The original file is saved to in.txt.back
before processing.
Change the \\n
to whatever you want as line break.
in.txt before:
{
"chatpattern" "MY REGEX FILTER"
}
{
"chatpattern" "MY REGEX FILTER"
}
{
"chatpattern" "MY REGEX FILTER"
}
in.txt after:
{
text1
"chatpattern" "MY REGEX FILTER"
}
{
text2
"chatpattern" "MY REGEX FILTER"
}
{
text3
"chatpattern" "MY REGEX FILTER"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.