Note that there are some explanatory texts on larger screens.

plurals
  1. POFloating Point - Regular expression
    primarykey
    data
    text
    <p>I am struggling to understand this simple regular expression. I have the following attempt:</p> <pre><code>[0-9]*\.?[0-9]* </code></pre> <p>I understand this as zero-to-many numeric digits, followed by one-to-zero periods and finally ending in zero-to-many numeric digits.</p> <p>I am not want to match anything other than exactly as above. I do not want positive/negative support or any other special support types. However, for some reason, the above also matches what appear to be random characters. All of the following for whatever reason match:</p> <ul> <li>f32</li> <li>32a</li> <li>32-</li> <li>=33</li> </ul> <p>In an answer, I am looking for:</p> <ul> <li>An explanation of why my regular expression does not work.</li> <li>A working version with an explanation of why it does work.</li> </ul> <p><strong>Edit</strong>: Due to what seems to be causing trouble, I have added the "QT" tag, that is the environment I am working with.</p> <p><strong>Edit</strong>: Due to continued confusion, I am going to add a bit of code. I am starting to think I am either misusing QT, or QT has a problem:</p> <pre><code>void subclassedQDialog::setupTxtFilters() { QRegExp numbers("^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$"); txtToFilter-&gt;setValidator(new QRegExpValidator(numbers,this)); } </code></pre> <p>This is from within a subclassed QDialog. txtToFilter is a QLineEdit. I can provide more code if someone can suggest what may be relevant. While the expression above is not the original, it is one of the ones from comments below and also fails in the same way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload