Regular Expression Pattern To Accept An Apostrophe - regex

I am using Regular Expression in Jquery to validate names.I am having this issue that i need a pattern which will allow an apostrophe in the name.That means it can have alphabets and a single apostrophe.
Valid: D'souza,Danny
Invalid: D''souza
Can anybody help me out with this.Currently I am using this pattern
var rxPattern = /^([a-zA-Z]+)$/;
Thanks

You probably need something like that:
[a-zA-Z]+('[a-zA-Z])?[a-zA-Z]*

Related

Regular Expression Pattern which should not allow ,;:|

I need the regular expression pattern which should not allow to put any of following characters into input in HTML
,;:|
You may get some idea from this.
[^,;:|]+
DEMO::: https://rubular.com/r/dKQzC1HrnMG88X

Checking url string in Regular Expression

Admit that I suck in writing regular expression. Please help me to solve how to write regular expression for success-apply founded in URL just like http://www.example.com/success-apply/
Assuming that the pattern success-apply changes:
example\.com\/([^\/]+)
# capture everything that is not a forward slash one or unlimited times
Here is this regex example with PCRE (PHP).
If you however only want to know if the string is there at all, regular expressions seem a bit of an overkill. Consider the following PHP code:
if (strpos($url, 'success-apply') !== FALSE) {
// do sth useful
}
Is this what you are looking for?
(success-apply)

Regex Expressions for Alphanumeric and Wild characters

I need to validate / search / find strings as below using regex pattern:
1/0.abc
1/0.ABC
1/2/1.xyz
1/.ddd
Can Someone help me with the regex pattern please
i think you need this :
^\d(?:\/\d)*\/?\.\w+$
this will validate your string with any type of extension
demo here : http://regex101.com/r/qE7gK5/1
in java :
^\\d(?:\\/\d)*\\/?\\.\\w+$
Depending on the language, the pattern may vary. For JavaScript, the following pattern will work:
/(\d+\/)+\d*\.[a-z]{3}/ig

QRegExp Pattern For URLs

I am trying to match google urls from some text that is stored in a variable, using the pattern below.
The urls use double quotes
QRegExp regExp;
regExp.setPattern("http://www.google.com/(.*)");
I manage to match the url but it unwontedly matches all of the text that is contained after it. I have tried using similar variants like the ones below, but they don't seem to work.
regExp.setPattern("http://www.google.com/(.*)\"is");
regExp.setPattern("http://www.google.com/^(.*)$\"");
Any help to get a regular expression that matches just the url alone.
Thanks in advance
Is there a reason you need/want to use a QRegExp?
You could use a QUrl most likely.
Even though it is impossible for us to know what is around the urls in your text (quotes ? parenthesis ? white spaces ?), we can create a better regular expression by trying to do a negative match of characters that cannot be part of the url:
QRegExp regExp;
regExp.setPattern("http://www.google.com/([^()\"' ]*)");
Then you just need to add more possible characters to this negative character class.

Using Regular Expression on Live Validation

I'm using LiveValidation (http://livevalidation.com/) to validate a form on my site in the client-side part.
However i'm having problems using the regular expressions:
the example on the website is not very clear and i'm trying to validate a field where i don't want to reject numbers with this:
var f1a = new LiveValidation('nome');
f1a.add( Validate.Format, { pattern: /[a-zA-Z]/i } );
or at least all non digit characters:
[^0-9] ???
are my regular expressions wrong?
or am i using wrongly the live validation with reg exp?
Thanks!
This regex matches input that is all alphabets.
/^[a-z]+$/i
The + is necessary for it to match multiple characters. Without it, the regex matches the first character and stops.
I recommend this website. It has a lot of samples and you can test the regex.
the i in the regex is the ignoreCase flag. When specified, matches are made irrespective of case.