Suppose I has 2 jsons:

    "action": "Handler:GET_DICTIONARY",
    "locale": "en",
    "data": {"dictionary_type":"EXCHANGE_RATES_AS_DICTIONARY"}


    "action": "Handler:GET_DICTIONARY",
    "locale": "en",
    "data": {"dictionary_type":"MTS"}

I need to select only second json by regexp. The unique text to identify second json are: on first line: GET_DICTIONARY

AND on third line:


What is a correct regexp for this?

I try this regexp but it not help:


1 Answer 1


The following input for re-search-forward will do:

GET_DICTIONARY\(.* C-q C-j \)\{2\}.*MTS

The parenthesis \( and \) define a group that is exactly two times repeated by \{2\}. The content of the group is a sequence of arbitrary many non-newline characters .* and a newline that is input with C-q C-j.

After the last newline the group is followed by arbitrary many non-newline-characters .* and then by MTS.

Your main errors were

  1. that you didn't admit for the non-newline characters and
  2. that you did only admit one newline.

The basic elements for regexps are described in the Emacs manual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.