Regular Expressions 101

Community Patterns

Takes a word with transcription from dictionary record

1

Regular Expression
PCRE (PHP <7.3)

/
^([\w]+)(?:[\s]|[,.;]|\n)*(?:\[.+?\](?:[\s]|[,.;]|\n)*)*
/
x

Description

//Original word and its translation/transcription may be delimited with end-of-line,space and punctuations symblos //There may or may not be a transcription (but we expect it always to be in square brackets) //As well some dictionaries provide several transcriptions for the same word, delimited by punctuation symbols Example of dictionary article to extract the word with transcription:

TRANSLATION

[trænz'leɪʃ(ə)n] , [trɑːn-], [-(t)s-] брит. / амер.

сущ.

перевод (с одного языка на другой, из одних единиц в другие)

уст. передвижение, перемещение, сдвиг, смещение

преобразование, изменение

юр. передача имущества

Submitted by anonymous - 8 years ago