logo
down
shadow

Regular expression for spaces and integers, but no 'double negative' sign


Regular expression for spaces and integers, but no 'double negative' sign

By : nDARQ
Date : October 17 2020, 03:08 PM
this one helps. Trying to find a regex for a string containing only numbers and single spaces (but no spaces at beginning and end) such as this: , Code
code :
^(?:-?\d+ )*(?:-?\d+)+$


Share : facebook icon twitter icon
Regular expression to match non-negative integers in PHP?

Regular expression to match non-negative integers in PHP?


By : filipogrand
Date : March 29 2020, 07:55 AM
should help you out Your regex: @^(?:[1-9][0-9]*)|0$@
says match those number that start with 1-9 followed by any digit 0 or more times OR match those numbers that end with 0.
code :
if($input >= 0)
 // $input is non -ve.
Regular Expression for positive and negative numbers int values separated by spaces

Regular Expression for positive and negative numbers int values separated by spaces


By : Yogi_P
Date : March 29 2020, 07:55 AM
it should still fix some issue I can give you a pattern that would work with Ruby (sorry, I haven't used C# for a while). This pattern will capture the numbers, if used with the scan function. I'm sure there will be something you can do with captures and groups in C# that is similar:
code :
pattern = /^\s*(
   [\-\+]?
   [0-9]+
 )
 (
   (\s+
     [\-\+]?
     [0-9]+
   )
 )*$/x

xs = ["9", "+9", "-9", "87", "+87", "-87", "9  87", "9 +87", "9  -87", "+9 87", 
"-9 87", "+9 +87", "-9 +87", "-9 87", "9 +9 -9", "9 +9  87", "9 +9  +87", 
"9 +9  -87", "9 +9 654", "9 +9 +654", "9 +9 -654", "9 -9  87", "9 -9  +87", 
"9 -9  -87", "9 -9 654", "9 -9 +654", "9 -9 -654", "9  87  +87", "9  87  -87", 
"9  87 654", "9  87 +654", "9  87 -654", "9  +87  -87", "9  +87 654", 
"9  +87 +654", "9  +87 -654", "9  -87 654", "9  -87 +654", "9  -87 -654", 
"9 654 +654", "9 654 -654", "9 +654 -654", "+9 -9  87", "+9 -9  +87", 
"+9 -9  -87", "+9 -9 654", "+9 -9 +654", "+9 -9 -654", "+9  87  +87", 
"+9  87  -87", "+9  87 654", "+9  87 +654", "+9  87 -654", "+9  +87  -87", 
"+9  +87 654", "+9  +87 +654", "+9  +87 -654", "+9  -87 654", "+9  -87 +654", 
"+9  -87 -654", "+9 654 +654", "+9 654 -654", "+9 +654 -654", "-9  87  +87", 
"-9  87  -87", "-9  87 654", "-9  87 +654", "-9  87 -654", "-9  +87  -87", 
"-9  +87 654", "-9  +87 +654", "-9  +87 -654", "-9  -87 654", "-9  -87 +654", 
"-9  -87 -654", "-9 654 +654", "-9 654 -654", "-9 +654 -654", " 87  +87  -87", 
" 87  +87 654", " 87  +87 +654", " 87  +87 -654", " 87  -87 654", 
" 87  -87 +654", " 87  -87 -654", " 87 654 +654", " 87 654 -654", 
" 87 +654 -654", " +87  -87 654", " +87  -87 +654", " +87  -87 -654", 
" +87 654 +654", " +87 654 -654", " +87 +654 -654", " -87 654 +654", 
" -87 654 -654", " -87 +654 -654", "654 +654 -654"]

xs.each{|x| printf("%15s: %s\n", x, x.scan(pattern).inspect) }
                  9: ["9"]
                 +9: ["+9"]
                 -9: ["-9"]
                 87: ["87"]
                +87: ["+87"]
                -87: ["-87"]
              9  87: ["9", "87"]
              9 +87: ["9", "+87"]
             9  -87: ["9", "-87"]
              +9 87: ["+9", "87"]
              -9 87: ["-9", "87"]
             +9 +87: ["+9", "+87"]
             -9 +87: ["-9", "+87"]
              -9 87: ["-9", "87"]
            9 +9 -9: ["9", "+9", "-9"]
           9 +9  87: ["9", "+9", "87"]
          9 +9  +87: ["9", "+9", "+87"]
          9 +9  -87: ["9", "+9", "-87"]
           9 +9 654: ["9", "+9", "654"]
          9 +9 +654: ["9", "+9", "+654"]
          9 +9 -654: ["9", "+9", "-654"]
           9 -9  87: ["9", "-9", "87"]
          9 -9  +87: ["9", "-9", "+87"]
          9 -9  -87: ["9", "-9", "-87"]
           9 -9 654: ["9", "-9", "654"]
          9 -9 +654: ["9", "-9", "+654"]
          9 -9 -654: ["9", "-9", "-654"]
         9  87  +87: ["9", "87", "+87"]
         9  87  -87: ["9", "87", "-87"]
          9  87 654: ["9", "87", "654"]
         9  87 +654: ["9", "87", "+654"]
         9  87 -654: ["9", "87", "-654"]
        9  +87  -87: ["9", "+87", "-87"]
         9  +87 654: ["9", "+87", "654"]
        9  +87 +654: ["9", "+87", "+654"]
        9  +87 -654: ["9", "+87", "-654"]
         9  -87 654: ["9", "-87", "654"]
        9  -87 +654: ["9", "-87", "+654"]
        9  -87 -654: ["9", "-87", "-654"]
         9 654 +654: ["9", "654", "+654"]
         9 654 -654: ["9", "654", "-654"]
        9 +654 -654: ["9", "+654", "-654"]
          +9 -9  87: ["+9", "-9", "87"]
         +9 -9  +87: ["+9", "-9", "+87"]
         +9 -9  -87: ["+9", "-9", "-87"]
          +9 -9 654: ["+9", "-9", "654"]
         +9 -9 +654: ["+9", "-9", "+654"]
         +9 -9 -654: ["+9", "-9", "-654"]
        +9  87  +87: ["+9", "87", "+87"]
        +9  87  -87: ["+9", "87", "-87"]
         +9  87 654: ["+9", "87", "654"]
        +9  87 +654: ["+9", "87", "+654"]
        +9  87 -654: ["+9", "87", "-654"]
       +9  +87  -87: ["+9", "+87", "-87"]
        +9  +87 654: ["+9", "+87", "654"]
       +9  +87 +654: ["+9", "+87", "+654"]
       +9  +87 -654: ["+9", "+87", "-654"]
        +9  -87 654: ["+9", "-87", "654"]
       +9  -87 +654: ["+9", "-87", "+654"]
       +9  -87 -654: ["+9", "-87", "-654"]
        +9 654 +654: ["+9", "654", "+654"]
        +9 654 -654: ["+9", "654", "-654"]
       +9 +654 -654: ["+9", "+654", "-654"]
        -9  87  +87: ["-9", "87", "+87"]
        -9  87  -87: ["-9", "87", "-87"]
         -9  87 654: ["-9", "87", "654"]
        -9  87 +654: ["-9", "87", "+654"]
        -9  87 -654: ["-9", "87", "-654"]
       -9  +87  -87: ["-9", "+87", "-87"]
        -9  +87 654: ["-9", "+87", "654"]
       -9  +87 +654: ["-9", "+87", "+654"]
       -9  +87 -654: ["-9", "+87", "-654"]
        -9  -87 654: ["-9", "-87", "654"]
       -9  -87 +654: ["-9", "-87", "+654"]
       -9  -87 -654: ["-9", "-87", "-654"]
        -9 654 +654: ["-9", "654", "+654"]
        -9 654 -654: ["-9", "654", "-654"]
       -9 +654 -654: ["-9", "+654", "-654"]
       87  +87  -87: ["87", "+87", "-87"]
        87  +87 654: ["87", "+87", "654"]
       87  +87 +654: ["87", "+87", "+654"]
       87  +87 -654: ["87", "+87", "-654"]
        87  -87 654: ["87", "-87", "654"]
       87  -87 +654: ["87", "-87", "+654"]
       87  -87 -654: ["87", "-87", "-654"]
        87 654 +654: ["87", "654", "+654"]
        87 654 -654: ["87", "654", "-654"]
       87 +654 -654: ["87", "+654", "-654"]
       +87  -87 654: ["+87", "-87", "654"]
      +87  -87 +654: ["+87", "-87", "+654"]
      +87  -87 -654: ["+87", "-87", "-654"]
       +87 654 +654: ["+87", "654", "+654"]
       +87 654 -654: ["+87", "654", "-654"]
      +87 +654 -654: ["+87", "+654", "-654"]
       -87 654 +654: ["-87", "654", "+654"]
       -87 654 -654: ["-87", "654", "-654"]
      -87 +654 -654: ["-87", "+654", "-654"]
      654 +654 -654: ["654", "+654", "-654"]
Regular expression which allows numbers, spaces, plus sign, hyphen and brackets

Regular expression which allows numbers, spaces, plus sign, hyphen and brackets


By : Viquar
Date : March 29 2020, 07:55 AM
this one helps. I am using jquery validator where I have added a method to validate a string which allow only numbers, spaces, plus sign, hyphen and brackets. Number is mandatory in the string but other charterer is optional. , You can add the required characters into character class as
code :
/^(?=.*[0-9])[- +()0-9]+$/
/^[- +()]*[0-9][- +()0-9]*$/
regular expression allowing numbers starting with option plus sign and spaces and minus sign in between numbers

regular expression allowing numbers starting with option plus sign and spaces and minus sign in between numbers


By : Sergei
Date : March 29 2020, 07:55 AM
Does that help I am looking for regular expression that allows , Changes you should make
code :
^\+?[-0-9 _]{7,}$
negative numeric values and negative sign at the end . Need an expression to format the negative sign from the end to th

negative numeric values and negative sign at the end . Need an expression to format the negative sign from the end to th


By : Don Temino
Date : March 29 2020, 07:55 AM
it should still fix some issue I have values which are numeric and negative and negative sign at the end . Need an expression to format the negative sign from the end to the front of the numeric values , Assuming the value is a string, then:
code :
select (case when val like '%-' then '-' + replace(val, '-', '')
             else val
        end)
Related Posts Related Posts :
  • How to create a jar with tests and run it from another version of project?
  • SelectOutput malfunctioning
  • How to display time in HHhMM a format in java ?
  • Is this the right way to change the charset of a String?
  • Apache-poi Restrict the user to select only the values of drop down list
  • Junit4 with Parameterized Test
  • How to print server responses using LoggingFeature in Dropwizard 1.0.2?
  • rabbitmq setting requeue in spring xd
  • Evaluator Expression: How to know if the input is wrong
  • Drawing a JLabel with X,Y coordinate of the center
  • How to check when a bookmark placed inside a cell?
  • Access fields in class
  • What are all the events captured by Websphere JAVA_DUMP_OPTS conditions?
  • About compile servlets from command line: the provided solution didn't work
  • RegEx to extract text between tags in Java
  • JSON ObjectMapper with javac "-parameters" behaves when run via maven, not via InteliJ IDEA
  • datepickerdialog hide calendar and change my date picker view to standard mode
  • How to create config properties for tinylog at runtime with User preferences
  • MessageArrived MQTT paho library
  • Why java doesn't allow to create instance of inner class?
  • Getting NullPointerException while using Lambda expression
  • Reading values from a text file and separating into String and double
  • Gson: skip different fields with different gsons
  • Java this in parent and child not working as expected
  • Java Android - close application (notifications) after swiping in recents
  • I am using Authorize.net payment gateway and doing transaction through Direct Post Method,is it possible to just validat
  • Java Agent wont load into JVM
  • android error: The RealmClass annotation does not support nested classes
  • Hadoop: There are 0 datanodes running and no nodes & cannot connect to namenode
  • Return Response arraylist and 1 attribute
  • Java, why do my lines always white out in BlueJ?
  • starting apache drill process with java API?
  • Configuring a Maven plugin twice in a pom.xml
  • How to work with Lombok?
  • How to parse list of object from Json Object
  • Adding certificate in .cer format into to .bks keystore
  • String array initialization using for loop
  • Dynamic element inside several 'li'
  • Unable to upload a file to Spring REST service via RestTemplate
  • Scala: Why java.lang.IllegalArgumentException: Cannot format given Object as a Date?
  • How does CoreOS allocates memory to a Docker container?
  • Repaint never reaches paintComponent();
  • Instantiating a generic class in a generic class
  • Case insensitive path startsWIth endsWith
  • Deleting directory in finally block?
  • How to include resources from src/main/java
  • Cant assign found item to variable as array
  • add(T) in List cannot be applied to Java.lang.Number
  • Spring Data JPA Many to Many with extra column
  • How to index a boolean @Field in Hibernate Search if the field is not in the db table
  • Modify and access value outside a thread class
  • How to skip @Param in @Query if is null or empty in Spring Data JPA
  • Using AssertJ, how do I perform complex assertions on the contents of a list?
  • Get the corner value of dienantion array in java
  • How can I delete the available state in a local cache?
  • Can't get rid of the ugly border around ImageButton
  • Togglez feature activation based on input parameters from call
  • Passing confirmation to JSP from servlet, getting errors
  • How to check the date and timestamp is before 20mins
  • Java: How does a call to the super class constructor inside of a child class constructor work?
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com