In InDesign I was hoping [\l]{4}(?=\s)
will find the last four letters of words, but the GREP did not work. I wanted to put it in the header of page as the suffix. Was doing magic with \b
and $
, nothing worked. And http://regex101.com/r/uQ7xR3/1 does not work in InDesign, because it's php flavour.
Because there are several additional conditions. If the 5th letter is h
, then instead of 4 we should take 5 last letters of each word. But we do not take anything separated by an \s
, nor do we take ...
or anything inside |
(like | ā |
).
virūpacakṣus
dharmacakṣus
nayacakṣus
sūryacakṣus
divyacakṣus
saṃgrah
āsaṃgrah
upasaṃgrah
pratisaṃgrah
abhisaṃgrah
anusaṃgrah
Update. Let me add more limitations. Not just a "h", but if there are these combinations kh|gh|ch|jh|ṭh|ḍh|th|dh|ph|bh
, do not take only last 4, but last 5 letters. Same with ai|au - they should not be split.
General case:
1) From vṛddhāpacāyitva
take itva
.
Two exclusions:
2) From nakhāli
take khāli
instead of just hāli
, because kh
is treated like a single letter in devanagari script. Identically with kh|gh|ch|jh|ṭh|ḍh|th|dh|ph|bh
.
From mirikha
take rikha
instead of just ikha
, because kh
is treated like a single letter in devanagari script. Identically with kh|gh|ch|jh|ṭh|ḍh|th|dh|ph|bh
.
3) From mahahrauḍ
take hrauḍ
instead of just rauḍ
, because au
is treated like a single letter in devanagari script, so ai|au is like a single letter.
From ekaikaivat
take aivat
instead of just ivat
, because ai
is treated like a single letter in devanagari script, so ai|au is like a single letter.