1

I need to extract width and height from the paper trim size i.e "228 x 152"

For example width = 228 and height 152

how to extract from this string "228 x 152"?

I need regex to read width and height from the string.

JaRoi
  • 23
  • 8
  • Looks like you are looking to create a regex, but do not know where to get started. Please check [Reference - What does this regex mean](https://stackoverflow.com/questions/22937618) resource, it has plenty of hints. Also, refer to [Learning Regular Expressions](https://stackoverflow.com/a/2759417/3832970) post for some basic regex info. Once you get some expression ready and still have issues with the solution, please edit the question with the latest details and we'll be glad to help you fix the problem. – Wiktor Stribiżew Jun 27 '19 at 07:35
  • I have solved it this way. StringHandling.EREPLACE("228 x 152","x.*","") – JaRoi Jul 24 '19 at 04:05
  • That is, you only got `228`, right? So, to get width, you need `StringHandling.EREPLACE("228 x 152"," x.*","")` and to get height, you need `StringHandling.EREPLACE("228 x 152","^[0-9]+ x ","")`, right? – Wiktor Stribiżew Jul 24 '19 at 10:37
  • I do this way StringHandling.EREPLACE("228 x 152",".*x","") – JaRoi Jul 26 '19 at 03:13

1 Answers1

1

To get width, you need 

StringHandling.EREPLACE("228 x 152"," *x.*","")

To get the height, you need 

StringHandling.EREPLACE("228 x 152",".*x *","")

The * matches zero or more spaces and .* matches any 0 or more chars as many as possible.

Wiktor Stribiżew
  • 484,719
  • 26
  • 302
  • 397