Jump to content

Recommended Posts

Examples:

input: (n!/(1+n))

output: frac{n!}{1+n}

 

input: ((n+11)!/(n-k)^(-1))

output: frac{(n+11)!}{(n-k)^(-1)}

 

input: (9/10)

output: frac{9}{10}

 

The following regex works if there are no sub parentheses.

\(([^\/\)]*)\/([^\)]*)\)

 

The following does matching parentheses

@\((([^()]++|\((?:[^()]++|(?R))+\))+)\)@

 

I just can not figure out how to "combine them". If you would more examples let me know.

 

Link to comment
https://forums.phpfreaks.com/topic/223709-matching-parentheses-with-division/
Share on other sites

Sorry I didn't make this clear before. The division sign will not always be the only division sign. There could be multiple signs and you don't always want to put it into frac{}{}.

For example ((n+11)!/(n-k)^(-1))+(11)/(2)

your code would output: frac{(n+11)!}{(n-k)^(-1))+(11)}{(2}

what I would like: frac{(n+11)!}{(n-k)^(-1)}+(11)/(2)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.