How to allow only specific letters, numbers and symbols in input string

Hi all
i'm new to java and trying to program a polynom calculator.
so, you can enter a polynom string like for example "2.1x^3 + 3x^2 - 1". this all works fine.
but i only need numbers, some special symbols and only the letter x which will be the variable you can enter here, otherwise a message should be displayed that i entered an invalid character or symbol. and is it also possible to check that there is a space before and after a + or - sing?
the input string i'm reading it in with: String inputString = TastaturRead.readString();
anyone out there who can help me?
many thanks in advance.

Please don't cross-post.
Again, this looks backwards here. You seem to be using the string you want to split as the regex string, but again, I'm no expert here.
import java.util.regex.*;
public class Splitter {
    public static void main(String[] args) throws Exception {
        // Create a pattern to match breaks
        String pattern = "[+|-]+";
        Pattern p = Pattern.compile(pattern);
        // Split input with the pattern
        String input = "-5x^3+8x^2 - 2";
        //This smells wrong to me, backwards
        String[] result = p.split(input);
        for (int i=0; i<result.length; i++)
            System.out.println(result);
//This looks better to me.
result = input.split(pattern);
for (int i = 0; i < result.length; i++)
System.out.println(result[i]);

Similar Messages

  • How can I add three binary numbers and then convert to string (Hex format)?

    Hi All,
    I have my problem "half" resolved, but need some assistance on the final piece.  Overall, I need to take three string values (hex format), convert them to binary, add them and then convert back to a string (hex format).  If that doesn't make sense maybe this will:
    Final Result (My target) = 0xCC
     = 0x03 + 0x01 + 0x04
              = 0x03; 0011b
              = 0x01; 0001b
              = 0x04; 0100b
    For my app, we are dropping "masking" some of the bits so that we get 1 byte:
              = 0x03; 11b
              = 0x01; 001b
              = 0x04; 100b
    So...
    11001100b = 0xCC
    In my VI, I am taking each initial string [0x03,0x01 and 0x04] type casting them to U8.  Next I need to "mask" the binary values as shown above and then add them.  I am not sure how to do this in LV??
    Thanks for the help,
    Bryan

    Hi Bryan,
    there's a conversion palette in the string palette, ever looked at those functions?
    The rest is pure simple math:
    It's the straight-forward way, there are other possibilities too!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • When I try to buy ibooks from my ipad, the virtual keyboard is not the same as my computer, and since my password consists of letters, numbers and symbols my ipad keeps showing that my password is incorrect. Is there any way around this please?

     

    The keys on the sides of the space bar will shift the keys to a different set of characters. Pressing the ".?123" key takes you to another layout. On that layout the "#+=" key will shift to another set of characters. Between those 3 layouts you should have access to all of the symbols printed on a regular keyboard. You might want to check your keyboard and international settings in the Settings app if you think that may be an issue. If you are using key combinations to get symbols that are not printed on the physical keyboard, let us know so we can see if there is a way to generate the character/code on the iPad keyboard.

  • How to allow only the specified users/groups to open my pdf files...

    Hi there,
    I'm looking for resources/documents describing how to allow only the specified users/groups to open my pdf files by the Java API...
    I've found a sample code creating a policy in the following document.
    http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/wwhelp/wwhimpl/js/html/w whelp.htm?context=sdkHelp&topic=learn_lc_sdk_invokeremoting
    ( API Quick Starts (Code Examples) > Rights Management Service API Quick Starts > Quick Start: Creating a new policy using the Java API )
    But the sample code doesn't set recepients( users/groups ) who can open the pdf file.
    How can I make it ?
    Any samples ? or Does anybody can tell me which Java classes/methods I should use ??
    Policy#addPolicyEntry(PolicyEntry policyEntry) ??
    PolicyEntry#setPrincipal(Principal principal) ??
    or none of them ?
    Any hints are appreciated !
    Thanks.

    I'm not exactly sure what you are tying to do here, but typical approach when issuing one PDF par user/groups scenario goes like:
    1. Create policy for specific purpose and add principal (user/group)
    2. Apply policy on server side
    3. Deliver the file (via email etc...)
    If you are looking for sample codes, try quick start.
    http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/wwhelp/wwhimpl/js/html/w whelp.htm?&accessible=true
    If you go "API Quick Start/Rights Management Service API Quick Starts", you might find something useful. I think you need "Creating Policies" or "Modifying Policies" for step 1 above, and "Applying Policies to PDF Documents" for step 2.
    Hope this helps.

  • I am trying to fill in a form in adobe exportpdf. How can I fill in numbers and symbols? Parenthesis, dollar sign etc.

    I am trying to fill in a form in adobe exportpdf. How can I fill in numbers and symbols? Parenthesis, dollar sign etc.

    Hi;
    Can you provide a little more detail, maybe a screenshot?  ExportPDF only converts PDFs to other file types, what exactly are you using to try to fill out the form?  The two Adobe form filling tools I would recommend would be:
    1) Adobe Reader - a free download you can install on your computer and can be used to fill out most any form.  For numbers, symbols etc it can depend on the field you are entering data into, some fields have restrictions, but you would use those keys on your keyboard, if nothing is entered then that field probably has restrictions.
    2) Adobe Fill & Sign: https://cloud.acrobat.com/fillsign - using the Fill & Sign tab on the acrobat.com website you can fill out most PDFs.  To enter numbers, symbols, etc you would simply add them using your keyboard.
    Thanks,
    Josh

  • I have a computer Mac, and I enter in the module, so that it can unlock, but I cant not write does not accept letters, numbers or symbols, and asks me is waiting for root device, what can I do....

    I have a computer Mac, and I enter in the module, so that it can unlock, but I cant not write does not accept letters, numbers or symbols, and asks me is waiting for root device, What can I do?....

    Some more details will probably be required.  The OS X version will help, as a start.
    If you have the diagnostics DVD disk, boot that and see if there are any errors logged.
    If this is OS X that's installed on a MacBook Air that you're using, then some of the usual triggers and approaches for resolving the still waiting for root device errors are discussed here.  Have a look at that, and see if something in that sequence looks familiar, whether the PRAM reset or the safe boot helps or works here.
    If there's any anti-malware, I/O accellerator, antivirus tools or similar installed, get rid of it.  At least for testing.
    There's a mention of "other OS" in your footer.  If not OS X, what is the operating system in use here?  If this is some other hardware or software involved, then the triggers for this error can vary.  Widely.

  • How can i change my ipads numbers and calender to english not arabic?

    how can i change my ipads numbers and calender to english not arabic?

    I am a Canadian and I purchased myPad in Mexico everything was in Espania/Spanish I went into settings and changed location to Canada, English and this pretty much fixed everything for me,I however still get some websites in Spanish for eg: when I google search.I resolved this problem with resetting google search to my location in Canada.

  • Keyboard only produces numbers and symbols regardless of which key is pressed.  Is there another option to deleting all and reloading Bootcamp?

    Repetitive pressing of one keyboard key produces different varied numbers and symbols.

    I actually ran into this same issue and created a standalone app that restores the Snow Leopard functionality. It seems to be a bug in the current implementation, hopefully Apple fix it soon.
    Check out my blog for the info and the download: http://nickbona.com/blog/2011/12/12/speak-selected-text-in-os-x-lion.html
    If you find it useful, feel free to share it with as many people as you'd like, just please post a link to that posting.
    Nick

  • Word Count - ignore numbers and symbols

    Hi Guys,
    can anyone tell me how to ignore numbers and symbols by adjusting the script below, i.e., just counting letters in a whole document.
    myDoc = app.activeDocument
    h = 0
    for ( var j = 0; myDoc.stories.length > j; j++) {
    h = myDoc.stories[j].words.length + h
    alert("You have " + h + " words in this document" )
    Cheers,
    Samuel

    In CS3 and later you can use this:
    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat = "[\\u\\l][-\\u\\l]+";
    found = app.documents[0].findGrep ();
    alert ("You have " + found.length + " words in this document.")
    A "word" is defined here as any string of upper- and lower-case letters and hyphens. Maybe that's too strict, but you can tweak the GREP to suit your needs.
    Peter

  • TS3280 How can i enable both paired bluetooth and ios keyboard input at the same time?

    How can i enable both paired bluetooth and ios keyboard input at the same time?
    This is needed for the app im working on. Need some user input via keypad as well as scanner input via a paired bluetooth scanner.

    You probably should not be using a keyboard bluetooth profile for a scanner, I am not a developer for apple so do not know the location for you to find out the correct profile you should be using for an input device that is not a keyboard. Sorry,
    I am sure if you navigate the apple developer site you will probaly finmd what you're looking for.
    https://developer.apple.com

  • Does LabView program behave differentl​y under Traditiona​l Chinese version from regular English version. The program reads in numbers and characters from input files.

    Does LabView program behave differently under Traditional Chinese version from regular English version. The program reads in numbers and characters from input files.

    Hope this helps,
    Ankita

  • HT1349 my itunes gift card is missing letters/numbers and half printed on how do i retrieve my gift card if i can't read it

    How do we activate our itunes card when I can not read all the numbers and letters

    iTunes Store: Invalid, inactive, or illegible codes

  • SAP parameter or setting to allow only capital letters in password

    Hi,
    Is there any option, parameter or setting in SAP where the admin can allow users to use only capital letters in their passwords?
    I know a parameter which restricts the users to use a specific number of capital letters. But, i want users to use only caps in their password no matter how long it is.
    Please help.
    Thanks
    Vijay

    Theres no such parameter... and I don't understand why would you do that, that will make passwords less complex.
    In any case... if you limit the amount of caracters to say 8 and force 1 special caracter and 1 number, then you can set the minimun amount of capitals to 6 meaning all have to be capitals.
    Again, I wouldn't do that.
    Regards
    Juan

  • How to view only specific authentication requests in access tracker

    Requirement:
    How to view only "Healthy/Unhealthy" requests from a specific Webauth service.
    Solution:
    If we have more than one Webauth service (based on conditions such as Device type or NAS IP or posture status etc) and we need only Healthy/Unhealthy requests from a specific service in access tracker for administrative use; we need to create a custom Data filter.
    Configuration:
    Below are the steps to achieve the same:
          Navigate to Monitoring > Data filters > Click on "Add" option to create a new filter
          Specify a name on the "Filter" tab
          Select the "Rule" tab to specify the unique condition (to filter the access tracker request)
          Create the below conditions: 
                     ( Commonystem-Posture-Token CONTAINS Healthy ) 
                     -   AND   -   ( Commonervice CONTAINS Windows-health-check )
          5.        Save this filter
    Now we can use this Data filter in access tracker to only view Healthy Webauth requests from "Windows-health-check" service.
    Verification
    So now we can verify the output by looking at the access tracker. 
    At present we can see "Eight" webauth requests in access tracker. Now we want to see only Healthy web-auth request from "Windows-health-check" service.
    We change the data filter to the Custom "healthy-filter" and now only see one request in access tracker as per our requirement.

    Hi Vignesh,
    ANy luck on this ? I am trying the almost same thing...and stuck at same point.
    Please let us know if you have any more information.

  • Allowing only specific characters in input

    Hello,
    My projects were auditted for security and it was found a
    logged in user (only) could hack my programs because I was not
    being careful to keep certain characters from being input, not just
    pointy brackets and pound signs. I am now told to do no client side
    checking.
    I am thinking to define an allowable character list to
    checking each input box character by character.
    What is a faster and more efficient way than looping through
    each input value's characters 1 by 1 and using find() and to check
    if those characters are in the list of good characters?
    Thanks.

    If you feel you can make use of it, this might be a place to
    start:
    [^-_,\.@a-zA-Z0-9\s]
    I use this reg exp as part of a parameter to an refindnocase
    function inside a little udf I wrote to scrub user input. It's not
    the entire expression, and I don't feel comfortable simply posting
    the whole udf (not trying to be mysterious, but it's part of our
    online security, after all, and is the property of my employer).
    I think your approach of defining allowable characters,
    instead of trying to define non-allowable ones, makes a great deal
    of sense and is the approach that seems to be widely recommended.
    That's what I use the expression above to do...if the character
    ain't in that set, it gets deleted from the input string. It can
    extract a price even from an innocent string, though...note that if
    a user inputs "O'Brien" it'll come through as "OBrien" which for my
    purposes is no more than a minor inconvenience. YMMV.
    If that code makes no sense, spend an hour reading up on Reg
    Expressions and you'll get it.
    Bob's advice to become familiar with cfqueryparam is, of
    course, excellent.

Maybe you are looking for

  • Transfer music Ipod to Itunes

    In changing my computer OS to windows 2007 I lost my Itunes library. I reloaded same but have lost the songs that I downloaded from CDs. I have these on my Ipod and want to know whether I can trancsfer ny music from my Ipod to Itunes on the computer.

  • DVD ejecting with no reason

    I have a old T40 with windows XP. Recently my DVD start ejecting with no reason. any solution? Cow Thinpad T40 + X100e(athlon Dual core L335, window 7 home premium)

  • Display seles unit convert of material at inventory cube

    Hello all, At Report on the Inventory Cube ( 0MM_C02) i need to display the sales unit of material. at material master in ecc the data exist at tran mm03 --- > additional data -----> unit of messure - all the convertion unit of measure. exp: base uni

  • Disillusion Setting In

    Having had my Mac for some weeks now I am becoming increasingly disappointed with it, particularly when it comes to Pages. I couldn't find how to delete a Page document. Nothing in the menu bar at the top of the screen; not able to drag to trash from

  • Is there a "snap-to-playhead" feature?

    I'm brand new to Captivate (using 8), and am finding myself constantly needing to adjust the right (end) edge... usually to the playhead. Is there a 'snap to playhead' feature? Is anyone else having this issue?