Valid URL+regex

hi, i want to implement a function that will check for validity of a URL, which user inputs in a textbox. i have to accomplish thru regular expressions (or any other methods are also acceptible).
Suppose user inputs 'http://www.yahoo.com' it will say valid url
'http://[email protected]' it should say incorrect
'http://www.yahoo+.com it should say incorrect
'http://www.yahoo.com@ it should say incorrect
i have tried to implement this but it is not working correctly
Pattern urlPattern = Pattern.compile("www\\.(.+[[a-z][0-9]&&[^~!@#$%^&*]])\\.(.+[a-z])");

I usually look on google for this kind of thing: http://www.google.co.uk/search?num=100&hl=en&ie=UTF-8&safe=off&q=%22valid+url%22+%22regular+expression%22&meta=

Similar Messages

  • Error Illegal access to the viewer. Please use a valid URL

    Hi, One question:
    Illegal access to the viewer. Please use a valid URL?
    Pls, any comment with this error.
    Regards
    LEJS

    Check the KBA 1892338 - Error: "illegal access to the viewer, please use a valid url" while viewing webi reports from BI Launchpad.This may be because of licence being expired.

  • Ume.logon.branding_image to a valid URL

    Hello Friends,
    I know that : "As of EP6 SP2, it is possible to change the branding image without having to modify code. Instead, you can set the user management property ume.logon.branding_image to a valid URL. For example:
    ume.logon.branding_image=/irj/newImage.gif.
    ume.logon.branding_image=http://www.company.com/Image.gif"
    On my system if i try to save the modifications the URL changed to
    ume.logon.branding_image=http\://www.company.....
    http\:// and not http://
    Could you please help me?
    Regards,
    Fth

    Hello,
    usually this occurs, or in cases of developing on unix/luinux/C/etc. it's required to set special commands like '/' or ':' out of their funktionality, the funktionality will be disabled with the presetting of the backshlash command sign '\'.
    So the stringset executing will be not interupted until the last sign is processed.
    Perhaps you should check your system environment at first.
    It seems, that the string processes a locally adress. In Windows environments such appearances occurs often, it also like a adress-string if you're typing in the browser a local file to show, here you must start like "file\://'
    I hope  it was helpfully and nearly correct.
    br.ct

  • Not a valid URL: Unexpected character found - Installation of SLD

    During the installation of SAP Solution Manager 4.0 Support Release 3 I am installing a local SLD (this is a test environment). When at the "Configure System Landscape Directory" phase of the installation I get the following error, java.net.MalformedURLException: Not a valid URL: Unexpected character found ['-' at position 18].
    Any help would be appreciated.
    ConfigMainExt state200
    TYPE=A<BR>STATE=<BR>INFO_SHORT=java.net.MalformedURLException: java.net.MalformedURLException: Not a valid URL: Unexpected character found ['-' at position 18]
         at com.tssap.dtr.client.lib.protocol.impl.URLScanner.next_token(URLScanner.java:587)
         at com.tssap.dtr.client.lib.protocol.URL.parse(URL.java:518)
         at com.tssap.dtr.client.lib.protocol.URL.<init>(URL.java:63)
         at com.sap.ctc.util.SLDConfig.importSldContent(SLDConfig.java:765)
         at com.sap.ctc.util.SLDConfig.performFunction(SLDConfig.java:154)
         at com.sap.ctc.util.ConfigServlet.doGet(ConfigServlet.java:74)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    //   => Importing Data : D:/usr/sap/A12/SYS/global/sld/model/CR_Content.zip URL=http://usbfg046dev-:50000 USER=J2EE_ADMIN ...
    ERROR: Not a valid URL: Unexpected character found ['-' at position 18]
    <BR>CONFIGURATION=

    During the installation of SAP Solution Manager 4.0 Support Release 3 I am installing a local SLD (this is a test environment). When at the "Configure System Landscape Directory" phase of the installation I get the following error, java.net.MalformedURLException: Not a valid URL: Unexpected character found ['-' at position 18].
    Any help would be appreciated.
    ConfigMainExt state200
    TYPE=A<BR>STATE=<BR>INFO_SHORT=java.net.MalformedURLException: java.net.MalformedURLException: Not a valid URL: Unexpected character found ['-' at position 18]
         at com.tssap.dtr.client.lib.protocol.impl.URLScanner.next_token(URLScanner.java:587)
         at com.tssap.dtr.client.lib.protocol.URL.parse(URL.java:518)
         at com.tssap.dtr.client.lib.protocol.URL.<init>(URL.java:63)
         at com.sap.ctc.util.SLDConfig.importSldContent(SLDConfig.java:765)
         at com.sap.ctc.util.SLDConfig.performFunction(SLDConfig.java:154)
         at com.sap.ctc.util.ConfigServlet.doGet(ConfigServlet.java:74)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    //   => Importing Data : D:/usr/sap/A12/SYS/global/sld/model/CR_Content.zip URL=http://usbfg046dev-:50000 USER=J2EE_ADMIN ...
    ERROR: Not a valid URL: Unexpected character found ['-' at position 18]
    <BR>CONFIGURATION=

  • Valid URL or Not

    Hi,
         I would like to know how to find a url is valid or not in scrollpane contentpath .
    Regrads,
    Kameshwaran A

    use the onLoadError event of the moviecliploader class to check the url before applying to your scroll pane's contentPath.

  • How to check the validation of RegEx

    Hi,
    My application needs users to enter RegEx. My question is how I can check the validation of the RegEx that users enter. The Class RegExp does not seem to provide any methods to check the validation of the RegEx.
    Regards,
    Haibin

    You would need to hand roll your own validator, unless someone knows of one that is out there. Flex does not validate RegEx.
    If this post answers your question or helps, please mark it as such.

  • Single word search - Firefox tries first DNS looup even though the word does not look like a valid URL (browser.fixup... is disabled).

    When I enter a correct domain name in the location bar, it is resolved without any problems ("domain.com"). When I enter multiple words, not constituting a valid domain ("some domain"), it is automatically searched in my preferred search engine. If I enter a single word ("domain"), which is _not_ a valid domain, Firefox still attempts to first resolve it (which takes about 15 seconds).
    Is there a way to disable or fix this behavior?
    browser.fixup.alternate.enabled;false
    browser.safebrowsing.remoteLookups;false
    keyword.URL;http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=

    It maybe better to use a (one letter) keyword bookmark if you want to do searches via the location bar. It is always possible that you want to access a local site without a TLD appended and in such cases you need to do a DNS look up.
    See http://kb.mozillazine.org/Using_keyword_searches

  • ShowDocument,  valid URL

    hi All,
    I am very new to Java and would appreciate any help!
    I have an applet running on our web server which our customers are using to search and look at files. Some files will have images (.pdf) that I would like for the customers to view in a new browser window.
    I was able to show a .pdf file in a new browser by using the showDocument method, and hardcoding the url. url1= "http:/mywebserver.com/file123.pdf"
    showDcoument(ur11)
    My question is... what is the best way for me to validate and see if this pdf file exists ? so that I can show a button for the customer to view this document.
    I am using the below method where xxx.pdf does not exist.. but it seems to always show the button even though xxx.pdf does not exist.
    try {
    url = new URL (http://mywebserver.com/xxx.pdf)
    viewImageButton.setVisible(true);
    catch (MalformedURLException e)
    {viewImageButton.setVisible(false)}
    Another thought I had was to use f.exists() to check if the file exists but that only works on local drives right ?
    I would appeciate any help.
    thank you !!

    thanks for the suggestion marvin. the problem with that approach is that a database of all devices and their capabilities would need to be maintained and checked against. if we're just talking ipads, iphones and ipod touches, that's reasonable; but there's a huge and growing number of android devices out in the wild and they all have different capabilities...?
    g

  • Firefox fails to load valid url from my desktop or from other links. after the failure it says try again and this always works 100% of the time. WHY??

    have many valid links on my desktop to locations I go to often. There is nothing wrong with the th links but about 20% of the time the connection will fail and I get a TRY Again message. It always connects 100% of the time on the second try. This occurs on 8 0r 10 different sites on a regular basis.

    Something you can try is resetting it all Settings > General > Reset > Reset all settings. Or go to Settings > Store &amp; sign out &amp; log back in. Another thing you can do is restore your ipod. This has happened to me but the only thing i did was that i created a new account but try doing the things above i just told you. :)

  • Firefox Home with Search panel does not load/appear. When I click the home icon a message appears that says Firefox is not a valid URL. Never did that before?

    Nothing different from the question. Firefox just does not load. When I place the mouse cursor over the home icon and do not click, a message panel seemingly powered by My Yahoo states "drag the AT&T globe to the left of the home icon in the toolbar and drop it there, then select "yes" from the pop up window and you are done." This was an action I did recently (not today) but don't see what this has to do with Firefox

    Do a malware check with some malware scanning programs.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br />
    <br />
    * http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    * http://www.superantispyware.com/ - SuperAntispyware
    * http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    * http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    * http://www.lavasoft.com/products/ad_aware_free.php - Ad-Aware Free
    See also:
    * "Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • How can I disable an Alert that indicates:"The URL is not valid and cannot be loaded".

    This Alert frequently pops up even after I've accessed a valid URL site on Firefox. Sometimes it takes 2 or 3 clicks to close the Alert window.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • How can I test if an URL is valid in Actionscript 3.0 ?

    Hy, everyone!
    I`m trying to make a function that tests to see if an URL is
    valid and return true if it is, false otherwise, so that I can use
    it in an 'if' statement.
    The way I try to do it is by using two event listeners for
    the 'contentLoaderInfo' proprety of a Loader: one for Event.OPEN(if
    this event is dispatched, then I know the URL is valid) and one for
    IOErrorEvent.IO_ERROR(if this event is dispatched, then I know the
    URL is not valid).
    But the problem is that by using the event handler functions,
    I leave the main URL tester function, and am unable to return a
    value from it. The way I thought of to get around this problem was
    to set a returnValue variable, to which to assign the return value
    of the two event handler functions and then just go 'return
    returnValue;'. But I don`t know how to return a value from a event
    handler function, and even if I did I still couldn`t do it that
    way, because it takes some time to dispatch those events and the
    'returnValue' variable would be undefined by the time I try to
    return it.
    I hope you understood what I tryed to explain above... Here`s
    some code to ilustrate this better(it`s not valid, it`s just so you
    understand my problem):
    private function testUrl(url:String):void {
    var returnValue:Boolean;
    var loader:Loader = new Loader();
    returnValue =
    loader.contentLoaderInfo.addEventListener(Event.OPEN, onGoodUrl);
    // This is a global variable to which I assign the value of
    'loader' so that I can close it from onGoodUrl
    _testLoader = loader;
    returnValue =
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,
    onBadUrl);
    loader.load(new URLRequest(url));
    // Even if I knew how to make an event handler that returns a
    value, I`d still have to wait for the loading to start, and I
    couldn`t return the value here:
    return returnValue;
    private function onGoodUrl(event:Event):Boolean {
    _testLoader.close();
    return true;
    private function onBadUrl(event:IOErrorEvent):Boolean {
    return false;
    You know any way to go around this problem? Or, for that
    matter, do you know any other way to test for a valid URL?
    Thank you for your time!

    You need to test httpStatus of the URLLoader. Streaming
    content undergoes a specific process when coming into Flash. The
    only issue with httpStatus is that it does not work for every
    browser....mostly Linux based systems and lesser programs on the
    evolutionary food chain. I have not experienced problems with IE or
    NS/FF on Vista at this point.
    1. Send Request
    2. Receive HTTP Status (HTTPStatusEvent.HTTP_STATUS)
    3a. Status Good - Begin Load (Event.OPEN)
    3b. Status Bad - 404 or Protected Filed
    (IOErrorEvent.IO_ERROR)
    4. Receive File - Downloading (ProgressEvent.PROGRESS)
    5. Download Complete (Event.COMPLETE)

  • Please enter a valid server URL when attempting to register on a custom sync server.

    This happens in the dialog when attempting to enter a custom sync server URL. Soon after typing http:// or https:// or even if you type any single character and wait a few seconds, the words "Please enter a vlid server URL" appear under the entry field next to a X in a red box.
    After entering a complete and valid URL the above text never goes away and the "next" button never gets enabled. Including after filling all the rest of the dialog. that error message remains and it is impossible to go forward.
    This happens on all of my desktop Firefox installations. I can't test it on a mobile device as it is not possible to create an account that way.
    I've tried it with and without a port number in the URL.

    Try to ask advice on IRC (irc.mozilla.org) in the #sync channel as mentioned at the bottom of the article.
    *http://docs.services.mozilla.com/howtos/run-sync.html

  • Regular expressions for URLs to match extensions

    I am working on a simple method that will assign a specific extension
    (e.g. ".jsp", ".php", ".cfm", etc.) to the end of a URL if it doesn't
    find anything marking a valid extension, however, I do not want to add
    an extension if one is found.
    Consider my code:
    import java.util.regex.Pattern;
    public static final String urlEndSlashPattern = "/?";
    public static final String urlQSPattern = "\\??([a-zA-Z0-9\\-_\\.]
    +=[^&]*&?)*";
    public static final String urlAnchorPattern = "#[^#]*$";
    public static void addExtToUrl(String url, String myExt, String[]
    exts) {
       StringBuffer sb = new StringBuffer();
       boolean hasExt = false;
       for (int i = 0; i < exts.length; i++) {
    sb.append(".").append(exts).append(urlEndSlashPattern).append(urlQSPatte�rn).append(urlAnchorPattern);
    if (Pattern.matches(sb.toString(), url)) {
    hasExt = true;
    sb = new StringBuffer();
    if (!hasExt) {
    url += "." + myExt;
    The issue I want to bring up is the regular expression pattern I'm
    using appears to fail.  I want to check and see if the URL I provide
    ends with a valid extension, followed by optional "/" or a query
    string or an anchor or any combination of these.
    Like say if I have
    http://www.blah.com/index.html
    Then don't add the ".jsp" extension
    But if I have
    http://www.blah.com/registration/
    Then I *want* to add the ".jsp" extension:
    http://www.blah.com/registration.jsp
    Or if I have:
    http://www.blah.com/registration/?foo=bar#baz
    Then it needs to change to
    http://www.blah.com/registration.jsp?foo=bar#baz
    But if I have
    http://www.blah.com/registration/index.php?foo=bar#baz
    Then I do *not* add the ".jsp" extension.
    Hope that makes sense now.  Bottom line is that the pattern above
    doesn't seem to work.  Ideas?
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Ok, just for fun, let's try it.
    URL: http://www.blah.com/?bar=baz#anchor
    Absolutely valid URL and something possible (remember, Balus, this is from a database entry, thus, it can be anything at all!)
    Let's split onto the last /
    Your last entry will be
    ?bar=baz#anchor
    So if I re-insert the .jsp that it would not find I get
    http://www.blah.com/.jsp?bar=baz#anchor
    INVALID URL
    Now let's try this one, BalusC:
    http://www.blah.com/index.jsp?forwardURL=http://www.wee.com/gotcha_balus/
    Now we split according to the ... last /
    http://www.blah.com/index.jsp?forwardURL=http://www.wee.com/gotcha_balus.jsp
    Valid URL, but possibly wrong when the query string value for "forwardURL" is read, thus, making the URL ultimately wrong.
    Two examples that show that splitting by the last / can't work here.

  • Need a regular expression for URL

    Regular expression: ^(udp|norm)://(?:(?:25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)(?(?=\\.?\\d)\\.)){4}:(6553[0-5]|655[0-2][0-9]\\d|65[0-4](\\d){2}|6[0-4](\\d){3}|[1-5](\\d){4}|[1-9](\\d){0,3})$
    Source: udp://125.3.4.121:23456
    Getting error:java.util.regex.PatternSyntaxException: Unknown inline modifier near index 54
    ^(udp|norm)://(?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(?=\.?\d)\.)){4}:(6553[0-5]|655[0-2][0-9]\d|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3})$

    paulcw wrote:
    I can't help wondering if a simpler solution would involve creating a java.net.URL object, passing it the string to be checked, and let URL do the parsing and an initial pass at checking the syntax. Then you could query URL for individual components for further checking (e.g., getting the transfer type to make sure it's one of the kinds you want). This approach would probably be more self-documenting, if nothing else.Nice idea, but java.net.URL doesn't actually do much work at all. It basically takes the protocol part, looks up a handler for it, and delegates everything else to that. The handlers themselves are down in the sun packages (or whatever your Java impl is) and since there isn't one for the OPs protocol, he'd have to write and register his own anyway, which kind-of negates the entire purpose of leveraging it.
    @OP: Paul's suggestion can still be of use. Apache, Codehaus and the like will have written their own protocol handlers, it's worth grabbing the source code for, say, Apache HttpClient, and seeing if they've got anything useful in there. Then again, who's to say that what's a valid URL for this 'norm' protocol, other than whoever designed the protocol?

Maybe you are looking for

  • Get form values from an uploaded offline interactive form.

    Hi, I have created a simple offline interactive form with 2 text input elements Email and PhoneNumber. I have created a button on the view. In the action, I have to get the values of the Email and PhoneNumber How to capture input values from an offli

  • Zoom in frame by frame is this possible?

    trying to zoom in on a massive scale frame by frame really - is there any way of doing this? I'm trying to animate and object frame by frame - or two frames at a time

  • Tax value stored table in purchase order

    Hi , i want to extract tax values of tax code from the Purchase order .  So plz tell me the tables where i can extract the tax values for a particular Purchase order at item level. Regards Kishore

  • Where does the manditory CF10 update needed to be copied to?

    We are running ColdFusion 10,282462 on a Windows Server 2008 R2 (64-bit) server.  There are several updates waiting to be downloaded and installed.  Before I can install these updates I need to download and install a manditory update.  I have downloa

  • Migrating CMSA Assets and Data from one server to another

    Hello, Is there an official way to migrate the data from one CMSA installation to another one?  In the near future we're going to need to move from our development machine into the production environment, and it would be great if there was a way to g