Thorsten,
It helps me a lot to think of regular expressions like programs and therefore to structure them like programs.
Here's how I define the REs that I think you want. (I assume that by "nested" you mean multiple.) I hope this helps.
,Doug
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst my-regex-plain-text
(concat "\\([[:space:]]*[^}]+\\)[[:space:]]*" ; Matches "123$%^ Чебурашка &*(0-="
)
"Regular expression defining what 'plain text' is.")
(defconst my-regex-bold-text
(concat "\\(!{\\)"
my-regex-plain-text
"\\(}\\)")
"Regular expression defining what 'bold text' is.")
(defconst my-regex-text
(concat "\\("
my-regex-plain-text
"\\|"
my-regex-bold-text
"\\)")
"Regular expression defining what 'text'.
Text is a mix of plain text and bold text.")
(defconst my-regex-list-item
(concat "\\(-{\\)"
my-regex-text "+"
"\\(}\\)")
"Regular expression defining what a 'list item' is.")
;;
;; Sunny day test code
;;
(defconst test-plain-text (list "foo"
"foo bar "
" foo bar baz bat"
" --- 123$%^ Чебурашка &*(0-= --- "))
(defconst test-bold-text (mapcar (lambda (text)
(concat "!{" text "}"))
test-plain-text))
(defconst test-list-item (mapcar (lambda (list-text)
(concat "-{" list-text "}"))
(append test-plain-text test-bold-text)))
(mapc (lambda (test-spec)
(let ((re (car test-spec))
(test-data (cdr test-spec)))
(mapc (lambda (item)
(if (string-match re item)
(message "PASS -- [[%s]] matches [[%s]]" re item)
(message "FAIL -- [[%s]] DIDN'T match [[%s]]" re item))
(sit-for 1))
test-data)))
(list (cons my-regex-plain-text test-plain-text)
(cons my-regex-bold-text test-bold-text)
(cons my-regex-list-item test-list-item)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;