3

I have text field that contains data in this format

1001.01:abcdefgh.1001.02:abcdefghijkl.1001.03:abcdefghfsdqfs.

I would like to insert an automatic line break so the result would be this :

1001.01:abcdefgh.
1001.02:abcdefghijkl.
1001.03:abcdefghfsdqfs.

other example with a field contains this

1245.01:qsdfqsdf.1245.02:qdfqsdmkj.1245.03:dfsdmfjmdf

I need that

1245.01:qsdfqsdf
1245.02:qdfqsdmkj.
1245.03:dfsdmfjmdf

So basically I need a way to insert a /n at the beginning of each xxxx.xx (x always being a number)

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Jul 1, 2022 at 14:53
3
  • Where exactly? To the field itself, to a new field or just in labeling? Commented Jul 1, 2022 at 14:57
  • And what exactly is your fixed sequence? Any string of a-z characters? Or .1001? Commented Jul 1, 2022 at 14:58
  • this should apply to all values contained in this field. Commented Jul 1, 2022 at 15:15

1 Answer 1

4

This regular expression will gave you the expected result :

regexp_replace(
 "your_field",
 '(\\d{4}[.]\\d{2})',
 '\n\1円'
)

It will insert a \n even for the first occurence, so first characters in your examples. If you want to avoid that the expression will be :

regexp_replace(
 "your_field",
 '(.)(\\d{4}[.]\\d{2})', -- (point `.` here means any single character)
 '\1円\n\2円'
)
answered Jul 1, 2022 at 14:58
2
  • just edited my question! Commented Jul 1, 2022 at 15:08
  • two things : 1) god, I love code. 2) you're the man! Commented Jul 1, 2022 at 15:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.