w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Matlab: If condition working on empty matrices, not working properly
I suspect there is a typo somewhere in code that you are not showing. Reducing your example to its most basic form (always a good idea to try to find a bug): a = []; b = [1 2 3]; display(~isempty(a)) display(~isempty(b)) if ~isempty(a) && ~isempty(b) disp('we passed the if') else disp('we are in the else') end Results in the output ans = 0 ans = 1 we are in the else Exactly as you would expect. If you get something different, then the code you are using isn't the code you are showing... is there a similar (mistyped) variable somewhere? Try doing a clear all, then run a minimal example that reproduces your problem.

Categories : Matlab

Regex not working in C# though working in Javascript
Strings are immutable, so replacement isn't done in place. dbId = Regex.Replace(dbId, @"(?:[@Name='.+?']|[@Details='.+?'])", String.Empty); Assign the result back to dbId Result: Test/Detail/Submit

Categories : C#

pmode in MATLAB 2013a is not working
I found a solution for both questions: 1) It is not possible to run any gui with pmode, so it is necessary to remove everything like uigetfile. 2) There is a bug in the 2013a version with Java on Mac. A possible work around is: Open Matlab Before doing anything, push the parallel computing button and select Manage Cluster Profiles Just close this window again Now you can use pmode, matlabpool, etc I patch is coming available but is not working for everybody.

Categories : Osx

Matlab ksdensity not working properly
The probability density estimate that ksdensity returns is based off the assumption of a normal kernal function. If your data has values near zero, you'll naturally get some overlap into the negative as the individual kernels are summed: (Image Source) A histogram won't have this problem since it only displays values that actually exist. To remedy the error, you can specify a different distribution (termed by Mathworks as the 'kernel smoother'), or even add a custom one. For example: [f,xi] = ksdensity(x,pts,'kernel','epanechnikov') replaces the normal distribution with an epanechnikov. Edit: ...and proving that you should always read the documentation first, I just discovered that you can limit your kernel density estimation to positive values only: x = gamrnd(5,7,1000,1); [f,xi]

Categories : Matlab

Multiple While loops working togther at once - MATLAB GUI
Instead of thinking of independent 'while' loops, think about one large one that optionally performs many sub-functions. % Pseudocode: while !do_exit if (button1_active) % Do some things done if (button2_active) % Do some different things done end Run this loop all the time, starting when you open the GUI, and exiting when the GUI closes. Alternately, think about using Timers. When you push a button, start a timer, which will will execute a callback function, which should perform a single iteration of your while loop. Use one timer per button, so they can be independently started and stopped. This has the added advantage of being able to control the execution rate. EDIT: Going with the timer approach, and listing only one camera. The other is the sa

Categories : Multithreading

regex not working as it should
Try this: ^(.){1};(d){4};(d){8};[A-K]{1};(d){7,8};(d){8};[A-Z ]{1,};[ d]{2};(d){8};(d){1};(d){1};$ Here what was happening in your regex ^(.){1};(d){4};(d){8};[A,K]{1};(d){7,8};(d){8};[A-Z ]{1,};[ ,d]{1};(d){8};(d){1};(d){1}; $ You have extra space before $ at the end. To specify range use - and not comma, Your range should be [A-K]. In [ ,d] range You have restricted it to 1 character {1} it should be {2} one for space and 1 for digit. Additional: You don't need to specify {1} as it will match one preceding token by default

Categories : Regex

Why isn't this regex working?
This is because the $ is a String and GString placeholder in groovy. Since you are using groovy to do the regex, you will have to escape anything that follows a $ or I am sure its possible hard code the expression in a string.. def matcher = someString =~ /([$\_]*)(.+?)([$\_]*)/

Categories : Regex

NET Regex: {1} not working
The pattern is not anchored to the end of the string. Try !Regex.IsMatch("1234567-8A","[0123456789]+-[0123456789K]$") Edit: or !Regex.IsMatch("1234567-8A","^[0123456789]+-[0123456789K]$") to anchor to both the start and end (to match the entire string). Regarding the {1}, the reason it's not necessary is that the character class [0123456789K] already means "match one character from this list". Adding {1} doesn't change that to mean "match one character from this list and nothing else after it". You need the $ anchor for that. See http://msdn.microsoft.com/en-us/library/az24scfc.aspx for information on anchors in the pattern.

Categories : C#

RegEx match not working
Use var reg = new RegExp(".*." + inputName); The square brackets mean: one character, which is one of those within the brackets. But you want several characzters, first a dot, then the first character of inputName, etc.

Categories : Javascript

PHP preg_match regex not working
OK, I found one that throws no errors: /^(?:(?:(?:1[./s-]?)(?!())?(?:((?=d{3})))?((?(?!(37|96))[2-9][0-8][0-9](?<!(11)))?[2-9])(?:((?<=(d{3}))?)?[./s-]?([0-9]{2}(?<!(11)))[./s-]?([0-9]{4}(?<!(555(01([0-9][0-9])|1212))))(?:[s]*(?:(?:x|ext|extn|ex)[.:]*|extension[:]?)?[s]*(d+))?$/ But you have to strip all not-numbers first: $input_number=preg_replace("[^0-9]","",$input_number); With that you can also format your number as you want: preg_match($pattern,$input_number); $number=$result[1] . "-" . $result[4] . "-" . $result[6]; Another way is to set the input mask with jQuery as described in the thread I mentioned above. Then the user can only input a valid phone number. I didn't find a good regexp that matches many formats.

Categories : PHP

C#.NET regex not working as expected
Your Regular Expression will only return one Match object with 2 subgroups. You can access those groups using the Groups collection of the Match object. Try something like: foreach (Match r in results) // In your case, there will only be 1 match here { foreach(Group group in r.Groups) // Loop through the groups within your match { Console.WriteLine(group.Value); } } This allows you to match multiple filenames in a single string, then loop through those matches, and grab each individual group from within the parent match. This makes a bit more sense than returning a single, flattened out array like some languages. Also, I'd consider giving your groups names: Regex regx = new Regex(@"^.*(?<filename>vdi(?<version>[0-9]+.[0-9]+).exe).*$"); Then, you can ref

Categories : C#

Regex not working on returned value
After comparing your regex to the sample-text, it appears that the issue is with "whitespace" in the sample-text itself. For instance, img src= will not match, but if you change it to img[s]+src=, it will. If you add this change throughout your regex you should end up with: <img[s]+src="images/cms/trinket/(.*).png"[s]+/></a>[s ]+<div[s]+style="[^"]+">(.*)</div> If you want to split the pattern onto multiple lines for readability, you can also use the x flag to "ignore pattern whitespace": preg_match_all('/<img[s]+src="images/cms/trinket/(.*).png"[s]+/></a>[s ]+ <div[s]+style="[^"]+">(.*)</div> /iUx', snd('test.php'), $matches, PREG_SET_ORDER); Note: I also updated the list of style val

Categories : PHP

Regex help needed not working for me
Try this: CaptchaServlet?rd=[^"]* ...As long as double quotes never appear as part of your data, this will work. :) And I highly recommend that you check out http://regexhero.net/, it will really help you when testing out .net regular expressions. EDIT: Improved the regex. Before it only worked for alphanumeric characters.

Categories : Dotnet

regex for date not working
^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.]([2-9][0-9])dd$ or ^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.][2-9]ddd$ or ^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.][2-9]d{3}$

Categories : Regex

Regex Pattern not working
\{[a-zA-Z]+\$[a-zA-Z]+>5}&&{[0-9]+\.[a-zA-Z]+==[0-9]+\} From looking at your previous question, I've assumed you want xxx and ppp to be any alphabetical string, and 5 to be any numeric string.

Categories : Java

Regex C code is not working on my mac osx
Actually, I think There is no errors in my code. The error was on a wrong link to regex.h. Once, I had coded for windows 7 and windows doesn't have /usr/include/regex.h directory (concept) so I installed the pcre package for windows in my current workspace with another regex.h file which was not compatible with my library pcre on my macbook. I cleaned my workspace and everything is back to normal.

Categories : C

regex not working for ZipCode
Within Javascript, you must escape all escape characters that are not used by the Javascript itself. Replace all backslashes with double backslashes within your regex, or (as noted by OP in that answer), denote a regex using forward slashes as boundary characters instead of listing it as a string that javascript will attempt to interpret. Forward slashes are syntactic sugar for explicitly writing new Regexp("...");.

Categories : Jquery

Why is this Regex not working on MVC unobtrusive validator?
Unless I'm misunderstanding the need, the regex should be: .*([Brand name]).* Or in other words, any character before and after, but must contain "[Brand name]".

Categories : C#

Regex for password policy not working
Someone correct me if im wrong but if the password can be any combination of the requirments you are looking for you may need to validate them one at a time, but if the pattern will always be the same, then one line of regex should do the trick, for instance if it will always be like so: Qwe12;,. [Capital Letter(s)][lowercase letter(s)][number(s)][special character(s)] Then one line of regex would be relatively easy to come up with to validate it but if it can be any combination of your requirments e.g. weQ,.12 or 12we,.Q Then it may be easier to validate one at a time so: First check for caps [A-Z] Then lowercase [a-z] Then numbers [0-9] Then special characters [[^$.|?*+()] Therefore if any of these fail password is invalid, hope this helps.

Categories : Dotnet

Ruby regex not working in Java
String line = "this is u.s.a. please come home. where are you"; String[] res = line.split("(?<=[.!?])\s+"); gives "this is u.s.a." "please come home." "where are you" Not the same a your Ruby version, but that version doesn’t appear sound to me anyway.

Categories : Java

Quick Regex Python 3 not working
Your second regular expression doesn't match: re.compile(r" i am ([w]+).*?$") because it starts with a space. Remove that initial space and it works fine: >>> a = 'i am struggling with life...' >>> reg = re.compile(r" i am ([w]+).*?$") >>> reg.findall(a) [] >>> reg = re.compile(r"i am ([w]+).*?$") >>> reg.findall(a) ['struggling'] The exception you see is thrown because the .format() method receives positional arguments as a tuple, tries to look up item 0 and as it was passed an empty set of arguments you get the IndexError.

Categories : Python

Regex pattern not working in a particular case
No, the quotes aren't the problem, and the regex does match in my tests. Are you sure you don't have a newline somewhere in-between, because the dot does not match them unless you use the /s modifier. So, please try $string = preg_replace( '/<span style="line-height: 17pt; font-family: helvetica; color: rgb(85, 85, 85); font-size: 13pt; font-weight: bold;">(.*?)</span>/s', '<h3>$1</h3>',$string);

Categories : Regex

unicode regex pattern not working
Here is what causing the exception: \u05[dDeE][0-9a-fA-F]}{2,} ^^^^ The java regular expression parser thinks you are trying to match a Unicode code point using the escape sequence uNNNN so it is giving an exception, because u requires four hexadecimal digits after it and there is only two of them, namely 05 so you need to change it to \u0005 if that is what you actually want. On the other hand, if you want to match \u in the target string, then you need to quad escape each backslash like this \\ so to match \u you need \\\\u. \\\\u05[dDeE][0-9a-fA-F]}{2,} Finally, if you want to match those Unicode code points literally in your target string then you need to modify our last expression a bit like this: (?:\\\\u05[dDeE][0-9a-fA-F]){2,} Edit: Since there is only one backslash in

Categories : Java

Regex.Replace is not working with separators
Regex.Replace() works on patterns, not separators. You are confusing it with String.Replace(). String.Replace(source, "-", string.empty) will work, but you will need to run this once per character. Regex.Replace(source, pattern, string.empty) will work better, but you need to use a RegEx pattern, not simple list the characters.

Categories : C#

REGEX validation not working on Rails 4
I guess you are missing A(beginning of string),z(end of string) PRICE_REGEX = /A[0-9]+z/ VALID_REGEX = /A[a-zA-Z0-9]*z/ Without A,z it could match anywhere in middle like in the case of Hello! Hi which would match..With A,z you would explicitly match from start till end of string without matching anywhere in between Refer to anchors in docs

Categories : Regex

Javascript regex match not working
Just removing the slashes works. pattern = function(name){"^"+name;} (name + "whatever").match(pattern(name)); // not null ("whatEver..NotName").match(pattern(name)); // null

Categories : Javascript

Django and regex not working with primary keys
Regex is for strings, but a pk is an integer. I'm not exactly sure what you are trying to do, but if you want to just get all States with pk between 0 and 9, you can use range: State.objects.filter(pk__range=(0, 9))

Categories : Regex

iOS regex pattern not working to match numbers
Try this regex: ^(?<!.)d*(.d+)?$ I added a negative look-behind assertion that means that no dot is allowed before that numbers. That should fix your problem.

Categories : IOS

Regex match only working with first catches (JavaScript)
What you need is the g flag. This way you get an additional match every time you call exec (until there are no further matches, and you get null). For the bonus, just include the (" and ") in the pattern, so that they are not captured. Finally, you might want to make the .+ ungreedy, otherwise you'll get funny surprises if there are multiple occurrences of this pattern in a single line: r = /{{ _("(.+?)") }}/ig; while(m = r.exec(fileContents) { // m[0] will contain the entire match // m[1] will contain the contents of the quotes } By the way, if "variable1" cannot contain escaped quotes (like "some"oddvariable"), then this regex should be slightly more efficient: r = /{{ _("([^"]*)") }}/ig

Categories : Regex

JavaScript RegEx - returns result but still not working
The reason you get note is capturing. Sets of parentheses make that part of the match available later (or within backreferences). Since you don't even need the parentheses for grouping, just remove them, if you don't want note. Then your spaces are optional (due to the ?) - hence, removing them in the string does not matter at all. Simply remove the ? or make it a + (so that more than one space is allowed). The other problem is, that . can match spaces as well. You should maybe be a bit more restrictive (this way you can also avoid ungreedy quantifiers, which are generally worse in performance): /<!ELEMENTs+S*s+([^)]*)>/i S matches anything except space character and [^)] matches anything except ) characters (it's a negated character class). In fact, you might want to exclude (

Categories : Javascript

Notepad++ v6.3.2 backreference regex replace not working
You must understand that $n refer to the capturing group number n. Since you don't have capturing groups in your search pattern, the group number 1 doesn't exist: You must use capturing parenthesis to define a group, example: search: (&lt;header) replace: $1 class="bold" Another example: search: (&lt;)(header) replace: $1$2 class="bold" Notice: $0 refers to the whole match (without define any capturing group). Then you can write: search: &lt;header replace: $0 class="bold"

Categories : Regex

Perl regex matching is working weired
This is because of unnecessary parenthesis. You got data from your groups stored in the array. Here is the working code: my @LANG = ($rc_file =~ /LANGUAGE LANG_[sS]*?#endif.* /{1,}/g);

Categories : Regex

JQuery Validation Email Regex not working
The regex you mentioned --which is well known by the way, will match 99% of emails. The only reason why I believe it's not working for you is that you are feeding the function emails with surrounding space or spacing, you must trim emails before testing them. -- Edit -- Your script (myscript.js:170) has an error: if (! check(isEmail, "email", "Invalid email.") ) { Remove quotes around email variable if (! check(isEmail, email, "Invalid email.") ) { Same thing for lines: 159 and 171

Categories : Jquery

RedirectMatch Regex only working on some browsers/machines
Clear your browser's cache first and use R=302 in your testing. Better use mod_rewrite for this. Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteRule ^(blog)/([^/]+)/?$ /$1 [L,R=302,NC] Once you verify it is working fine, replace R=302 to R=301. Avoid using R=301 (Permanent Redirect) while testing your mod_rewrite rules.

Categories : Regex

jQuery regex to remove non-numeric characters isn't working
Strings in JavaScript are immutable - you'll need to do var value= $(this).val().replace(/[^d.]/g, ''); $(this).val(value); the replace() function is going to return you the replaced string which you then have to set back on 'this'

Categories : Jquery

(SOLVED) Using Regex in Java based on working php code
Not an expert on Java, but shouldn't the strings escape double quotes and escapes? "<a href="http://www.mysite.com/photoid/(.*?)"><img src="(.*?)" alt="(.*?)" /></a>" or "<a\ href="http://www.mysite.com/photoid/(.*?)"><img\ src="(.*?)"\ alt="(.*?)"\ /></a>"

Categories : Java

Scala regex "starts with lowercase alphabets" not working
There are some issues with the match statement. s match is matching on the value of s which is checked against AlphabetPattern and _ which always evaluates to _ since s is never equal to "^([a-z]+)".r. Use one of the find methods in Scala.Util.Regex to look for a match with the given `Regex. For example, using findFirstIn to find the first match of a string in AlphabetPattern. scala> AlphabetPattern.findFirstIn("hello") res0: Option[String] = Some(hello) The stringMatch method using findFirstIn and a case statement: scala> def stringMatch(s: String) = AlphabetPattern findFirstIn s match { | case Some(s) => println("Found: " + s) | case None => println("Not found") | } stringMatch: (s:String)Unit scala> stringMatch("he

Categories : Regex

Regex Extract matched string from URL (working, better solution?)
The function is fine, but there's no need to use try-catch: function testLink (link) { var your_match = link.match(/test.com.*-([A-Z]{4,5}[0-9]{3,5})/i); // Not sure why do you want to return "false" rather than "null" return your_match ? your_match[1] : null; }

Categories : Javascript

Why is this generated ruby regex not working in the actual code?
try this: s = "4.4 out of 5 stars" p s[/([+-]?d*.d+)(?![-+0-9.])/] # >> "4.4" You can find this wayRegexp.new: Regexp.new('([+-]?\d*\.\d+)(?![-+0-9\.])') # => /([+-]?d*.d+)(?![-+0-9.])/

Categories : Ruby

Java split regex non-greedy match not working
The .*? in your regex matches any character except (0 or more times, matching the least amount possible). You can try the regular expression: :[^:]*?ced On another note, you should use a constant Pattern to avoid recompiling the expression every time, something like: private static final Pattern REGEX_PATTERN = Pattern.compile(":[^:]*?ced"); public static void main(String[] args) { String input = "abc|s:0:"gef";s:2:"ced""; System.out.println(java.util.Arrays.toString( REGEX_PATTERN.split(input) )); // prints "[abc|s:0:"gef";s:2, "]" }

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.