Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.snto-msu.net/showflat.php?Number=8735357&src=arc&showlite=
Дата изменения: Unknown
Дата индексирования: Wed Apr 13 12:39:07 2016
Кодировка: Windows-1251
emacs: roman numerals -> arabic numerals in regexp-replace - Public forum of MSU united student networks
Root | Google | Yandex | Mail.ru | Kommersant | Afisha | LAN Support
  
General Discussion >> Study (Archive)

Страницы: 1
scabarocci
добрый

Рег.: 26.09.2005
Сообщений: 1294
Рейтинг: 1030
  emacs: roman numerals -> arabic numerals in regexp-replace
      24.06.2009 17:41
-1

Отцы emacs'а,

как мне при при regexp-replace параллельно (и автоматически) переводить числа в римских цифрах в арабские?
Понятно, что я мог бы написать разные регекспы для всех нужных мне чисел, но хотелось бы сделать проще. Например, можно ли в выражении для замены вызывать команду емакса для какого-либо аргумента?

Что-то вроде:
code:
s/\([C.I,L,M,V,X]+\)\.\([0-9]+\.[0-9]+\)/\\eqref{eq:,(roman-to-arabic \1).\2}/


KOHTPA
Carpal Tunnel

Рег.: 22.01.2003
Сообщений: 33647
Рейтинг: 2374
  Re: emacs: roman numerals -> arabic numerals in regexp-replace [re: scabarocci]
      24.06.2009 18:15
1

code:
re-search-forward is an interactive built-in function in `C source code'. (re-search-forward REGEXP &optional BOUND NOERROR COUNT) Search forward from point for regular expression REGEXP. Set point to the end of the occurrence found, and return point. An optional second argument bounds the search; it is a buffer position. The match found must not extend after that position. Optional third argument, if t, means if fail just return nil (no error). If not nil and not t, move to limit of search and return nil. Optional fourth argument is repeat count--search for successive occurrences. See also the functions `match-beginning', `match-end', `match-string', and `replace-match'.


Вот так и действуй.

Пример:
code:
(while (re-search-forward "as?" nil t) (replace-match (concat (match-string 0) "__")))



---
Escape-Meta-Alt-Control-Shift

Страницы: 1

General Discussion >> Study (Archive)

Дополнительная информация
0 зарегистрированных и 0 анонимных пользователей просматривают этот форум.

Модераторы:  Basilio, The_Nameless_One 

Печать темы

Права
      Вы можете создавать новые темы
      Вы можете отвечать на сообщения
      HTML отключен
      UBBCode включен

Рейтинг:
Просмотров темы:

Переход в