Skip to main content
Known Participant
June 20, 2017
Question

Fractions in GREP

  • June 20, 2017
  • 2 replies
  • 1766 views

Is there a 'wildcard' or the equivalent through which I can select all fractions in GREP?

This topic has been closed for replies.

2 replies

Inspiring
June 20, 2017

Try this code: (\d+\.\d+)|[/\d]|\p{no}

vinny38
Legend
June 20, 2017

Hi

You should be more specific about the patterns of what you call "fractions".

Something like this: (a certain number of digits)+(a slash)+(a certain number of digits) maybe? Like 450/50

Or do you have separators? 27/1.5 or 27/1,5? Or even 1(space)500/2 or 5,500.50/3

Or maybe something completely different, possibly built with some math font?

Please provide more details, being as specific as possible (screenshots can also help)

Vinny

DativeAuthor
Known Participant
June 20, 2017

Okay so I need to be more specific, what I'm trying to do is find WxH measurements and flip them to HxW.

This is my code so far.

(.+)(~<×~<)(.+)(?=~<in\.)
and change to
$3$2$1

While this finds inches I need to be able to find centimetres as well. This is easy enough to do in two steps but I was hoping there was a more elegant solution with one. The structure of the measurements is always as follows

30 × 29 ⅞ in. (78 × 76 cm)

With the numbers varying obviously.

\d doesn't find fractions in the typeface I'm using because they're an individual glyph rather than composite parts.

I think I need a GREP expression like this (\d+~<(possible fraction))( ~<×~< )(\d~<(possible fraction))(?=~<in\.|~<cm\))

I seem to remember theres a way using a question mark you can say 'this may appear or it may not' so ideally I'd like it to be ?wildcard for fractions.

DativeAuthor
Known Participant
June 20, 2017

I should also note there's probably a way to do it without having to denote the fractions, I would just need the 'any character' expression to end at in. otherwise this happens.