User:Xenwolf/SandBox: Difference between revisions
→Testing factor notation: added input and legend |
→Testing factor notation: this is of course an important point |
||
| Line 126: | Line 126: | ||
== Testing factor notation == | == Testing factor notation == | ||
This solution requires valid (and sensible) input, there is no intelligence on board that would be able to detect zero divisions like <code>0^-1</code>. | |||
=== 1st version with mandatory exponents === | |||
Output: {{#replace:{{#regex: 2^-4 * 3^4 * 5^-1|/(\d+)\s*\^\s*(-?\d+)(\s*\*\s*)?/|\1<sup>\2</sup> \3 }}|*|⋅}} | : Input: <code>2^-4 * 3^4 * 5^-1</code> | ||
: Code: <code><nowiki>{{#replace:{{#regex: 2^-4 * 3^4 * 5^-1|/(\d+)\s*\^\s*(-?\d+)(\s*\*\s*)?/|\1<sup>\2</sup> \3&nbsp;}}|*|⋅}}</nowiki></code> | |||
: Output: {{#replace:{{#regex: 2^-4 * 3^4 * 5^-1|/(\d+)\s*\^\s*(-?\d+)(\s*\*\s*)?/|\1<sup>\2</sup> \3 }}|*|⋅}} | |||
=== 2nd version with optional exponents === | |||
: Input: <code>2^2 * 5 * 11^-1</code> | |||
: Code: <code><nowiki>{{#replace:{{#regex: 2^2 * 5 * 11^-1|/(\d+)(?:\s*\^\s*(-?\d+))?(\s*\*\s*)?/|\1<sup>\2</sup> \3&nbsp;}}|*|⋅}}</nowiki></code> | |||
: Output: {{#replace:{{#regex: 2^2 * 5 * 11^-1|/(\d+)(?:\s*\^\s*(-?\d+))?(\s*\*\s*)?/|\1<sup>\2</sup> \3 }}|*|⋅}} | |||