regex to produce duplicate string with modification

46 views Asked by At

I have string as "abc xyz pqr pyz" i want to make it like "abc xyz pqr pyz abcxyzpqrpyz". so basically take same string and duplicate it without spaces. I have to achieve this in solr "solr.PatternReplaceCharFilterFactory". One workout is to introduce intermediate field and use copy field. but i don't want to use intermediate field due to space constraints. I am looking for some like (([a-z]+)\s([a-z]+)\s([a-z]+)\s([a-z]+)) with replacement of \1 \2\3\4\5. this works for exactly 4 words in string but i am looking for something that will work for any number of words.

1

There are 1 answers

1
tahzibi.jafar On

I don't know about solr but why you don't remove spaces as following :

<filter class="solr.PatternReplaceFilterFactory" pattern="(\s+)" replacement="" replace="all" />

and then concat original string by this result