I am trying to match any blocks that has type:"Data"
in it and then replace it with the text I want.
A sample input is given below, there can be one or more of these:
layer {
name: "cifar"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
mean_file: "examples/cifar10/mean.binaryproto"
mirror: true
#crop_size: 20
}
# this is a comment!
data_param {
source: "examples/cifar10/cifar10_train_lmdb"
batch_size: 100
backend: LMDB
}
}
layer {
name: "cifar"
type: "Data"
top: "data"
top: "label"
include {
phase: TEST
}
transform_param {
mean_file: "examples/cifar10/mean.binaryproto"
}
data_param {
source: "examples/cifar10/cifar10_test_lmdb"
batch_size: 25
backend: LMDB
}
}
I came up with this regex :
((layer)( *)((\n))*{((.*?)(\n)*)*(type)( *):( *)("Data")((.*?)(\n)*)*)(.*?)(\n)}
I tried to model this :
find and select a block starting with layer,
there can be any number of space characters but after it
there should be a { character,
then there can be anything( for making it easier), and then
there should be a type followed by any number of spaces, then followed by "Data"
then anything can be there, until it is faced with a } character
But clearly this does not work properly. If I change the type in any of these layer blocks, nothing gets detected!, not even the layer which has the type : "Data"