w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Why is my regex not matching a C and the next letter?
[^PolicyChain:] is a character class that matches one character that is NOT (as indicated by the ^) among P,o,l,i,c,y,C,h,a,i,n or :. Then you match one character or more characters, lazily .+?. Since the regex has to start by matching a non-c (the first token), it cannot start matching at the C of ComplementaryUser. I suggest that your decision to use a character class is an error, and you want a positive lookbehind instead, such as (?<=^PolicyChain:): http://www.regular-expressions.info/refadv.html A positive lookbehind means, 'look behind my current position and attempt to match this lookbehind regex. If it does match, we can continue with the rest of the main regex. If it does not match, we cannot continue.' However note that lookaheads and lookbehinds are not POSIX-compliant,

Categories : Regex

Double letter matching using python regex
Maybe like this? Seems to work for me. r".*([a-z])1.*((?=(?!1))[a-z])2.*((?=(?!1))(?=(?!2))[a-z])3.*" (?=expr) is a non-consuming regular expression, and (?!expr) is regex NOT operator.

Categories : Python

Regex - stripping the first number or number and ajoining letter
It can be much simpler than that: var str = $('#_myTextbox').val();//"12a The Street" str = str.replace(/^w+s+/,'');//"The Street" Or for fixed number then optional letters format, use this regex instead: /^d+[a-z]*s+/ FYI: w is a 'word character', equating to [a-zA-Z0-9_] d is a digit, equating to [0-9]

Categories : Jquery

Regular Expression in c# to find letter then with capital letter for letter and Shift press form of other charecter?
Try following: var input = @"manoj kumar ma oj"; var pattern = new Regex(@"([a-z])\"); var replaced = pattern.Replace(input, m => m.Groups[1].ToString().ToUpper()); Console.WriteLine(replaced); UPDATE Map digits to shift-pressed form: string text= @"man1oj kumar ma o9j"; char[] shiftPressForms = ")!@#$%^&*(".ToCharArray(); Regex pattern = new Regex(@"([a-z])\"); Regex pattern_digit = new Regex(@"d"); string replaced = pattern.Replace(text, m => m.Groups[1].ToString().ToUpper()); replaced = pattern_digit.Replace(replaced, m => shiftPressForms[int.Parse(m.Value)].ToString()); Console.WriteLine(replaced);

Categories : C#

Regular Expression for matching number greater than specified decimal number
You could try this: (4.(1[0-9]*[1-9]|[2-9][0-9]*)|([5-9]|[1-9][0-9]+)(.[0-9]+)?) This will match: 4. followed by either: 1 followed by zero or more 0-9 and one or more 1-9 2-9 followed by zero or more 0-9 or Either 5-9 or 1-9 followed by one or more 0-9 followed by an optional decimal point and zero or more 0-9 Depending on how this will be used, you might want to consider adding start / end anchors around your pattern so that no other characters will be allowed: ^(4.(1[0-9]*[1-9]|[2-9][0-9]*)|([5-9]|[1-9][0-9]+)(.[0-9]+)?)$ You can test it here.

Categories : Regex

Switch between frames by number or letter
I see what you're trying to do. Here's how I've solved this problem: Part 1 The files that you use every day should be bookmarked. The reason is that you loose focus when you're reading any sort of menu, even as short as you describe. After some time with bookmarks, it becomes like touch-typing: you select the buffer without thinking about it. You can check out this question to see my system. I've got about 20 important files and buffers bookmarked and reachable in two keystrokes, e.g. μ k for keys.el and μ h for hooks.el. A nice bonus is that bookmark-bmenu-list shows all this stuff, so I can add/remove bookmarks easily rename bookmarks (renaming changes binding) it's clickable with mouse (sometimes useful) bookmark+ allows function bookmarks, so I've got org-agenda on μ a and m

Categories : Emacs

Turn a number of int to the correct sum
Your code is correct, you simply have to use a string $sum = "000000000117800"; echo number_format($sum, 2, ".", "."); prints ( http://ideone.com/534ATu ) 117.800.00 Although, you have to divide by 100 to get the fractional part right $sum = "000000000117800"; echo number_format($sum / 100, 2, ".", "."); which prints ( http://ideone.com/A5LFpS ) 1.178.00 the problem is when you assign $sum = 000000000117800; it is already being converted to 79 (as an octal value of $sum) and you cannot do anything about it. so why do strings work? Because number_format expetcs float as a first argument, so PHP performs conversion from string to float, which ignores leading 0's. As a result we have 117800 which we have to further divide by 100 to get decimals right, then we can use number_

Categories : PHP

Regex to validate information (Letter & Number only)
Try this: <?php $valid_submit = ($_REQUEST && isset($_REQUEST['do']) && $_REQUEST['do'] == 'submit') ? true : false; if ($valid_submit) { $ingame_name= ($_POST && isset($_POST['ingame_name'])) ? trim($_POST['ingame_name']) : ''; $email= ($_POST && isset($_POST['email'])) ? trim($_POST['email']) : ''; $invalidusername = ''; $invalidemail = ''; if(!preg_match("/^[A-Za-z0-9]+$/", $ingame_name)) { $invalidusername = '<font color=red>Oops, invalid username! Username may only contain numbers and letters.</font><br>'; $ingame_name = 'invalid'; } // This is a much more efficient method to validate email addresses if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $invalidemail = '<font col

Categories : Regex

VBScript to take PC's name, remove anything thats not a letter or number (i.e. A-BC-123 -> ABC123)
You can rename a computer using the Rename method of the Win32_ComputerSystem WMI class. For replacing non-alphanumeric characters use a regular expression. Set net = CreateObject("WScript.Network") Set wmi = GetObject("winmgmts://./root/cimv2") Set re = New RegExp re.Pattern = "[^a-z0-9]*" re.Global = True re.IgnoreCase = True For Each sys In wmi.ExecQuery("SELECT * FROM Win32_ComputerSystem") sys.Rename re.Replace(net.ComputerName, "") Next You need to reboot the computer for the name change to become effective: CreateObject("WScript.Shell").Run "shutdown -r -t 0" I don't think you need to re-join the system to the domain afterwards, but if you do, you can do it with the JoinDomainOrWorkgroup method of the same WMI class.

Categories : Vbscript

char datatype and returning a letter v number
Should be public char charAt(int location) { //TODO Finish method return 'a'; } Not " quotes , should be ' Prefer to read :Is there a difference between single and double quotes in Java?

Categories : Java

Check if input is number or letter javascript
You could use the isNaN Function. It returns true if the data is not a number. That would be something like that: function checkInp() { var x=document.forms["myForm"]["age"].value; if (isNaN(x)) // this is the code I need to change { alert("Must input numbers"); return false; } } Note: isNan considers 10.2 as a valid number.

Categories : Javascript

Isolate the first number after a letter with regular expressions
How about this? >>> re.sub('(d+)', 'subg<1>', "C7H19N3") 'Csub7Hsub19Nsub3' (d+) is a capturing group that matches 1 or more digits. g<1> is a way of referring to the saved group in the substitute string.

Categories : Python

Turn first part of string into a number in C
You're getting a segmentation fault since you're passing the value of an un-initialized integer (res_num) where sprintf() expects the address of a destination string buffer. You could use strtol() to convert the string to integer, or atoi(). That's not the problem, the problem is in the random memory overwrite of your sprintf() call. Also the printf() is referencing an unknown variable res; are you sure the above code even compiled? You can drop sprintf() and just use printf(): printf("found %d ", atoi(line + 22)); or, of course, store the number in a variable for further processing: const int res = atoi(line + 22); printf("by the way, res=%d ", res);

Categories : C

Jquery validate plugin check for at least 1 letter and 1 number
A JavaScript regex to match text with at least 1 letter and 1 number: /[a-z].*[0-9]|[0-9].*[a-z]/i It checks that the text contains either a letter and then a number, with other characters optionally in between, or a number and then a letter, with other characters optionally in between. Live demo of the regex

Categories : Jquery

how to get a number form value and turn it into string javascript
Don't use setAttribute to define event handlers. And you don't need to parse the value as you want to put it back in a string. Change document.getElementById("nextButton").setAttribute("onclick", multipleSetWindow+containerCuantityValue); to document.getElementById("nextButton").onclick = function(){ window.location='multiSet.html?type=multi'+containerCuantity.value; }

Categories : Javascript

CSS Pseudo Element Counters: can you increment an alphabet letter "a", "b", "c", etc instead of a number?
Yes, the second argument to counter() defines the type of counter used, as for the list-style-type from a regular ul or ol; for example: content: counter(chapter, lower-alpha); ul { counter-reset: listStyle; } ul li { margin-left: 1em; counter-increment: listStyle; } ul li::before { margin-right: 1em; content: counter(listStyle, lower-alpha); } <ul> <li>one</li> <li>two</li> <li>three</li> </ul> JS Fiddle demo. Others include: decimal, decimal-leading-zero, lower-roman, upper-roman, lower-greek, lower-latin, upper-latin, armenian, georgian, lower-alpha, upper-alpha References: list-style-type.

Categories : CSS

How can I turn a massive number of coordinates into a boundary or polygon?
Instead of having tomany points, you can put all those coordinates to form lines or polygons. For doing lines see the example from the simplekml Linestring tutorial. You can also learn from the MultiGeometry tutorial. Depending on the resolution that you need, you can also try to decimate your data with python before passing it to kml.

Categories : Python

Android: Random number decides players' turn
first notice that your toast command is not complete, and should be: Toast.makeText(getApplicationContext(), playerOneName + " won the first move!", Toast.LENGTH_SHORT).show(); then you'll have a better look on what's what

Categories : Java

Default number of players in a turn-based game? (OS X)
Set defaultNumberOfPlayers to the value you desire. In this case, it is set to match the minimum number of players. - (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers viewController:(UIViewController *)viewController { if (!gameCenterAvailable) return; presentingViewController = viewController; GKMatchRequest *request = [[GKMatchRequest alloc] init]; request.minPlayers = minPlayers; request.maxPlayers = maxPlayers; request.defaultNumberOfPlayers = minPlayers; GKTurnBasedMatchmakerViewController *mmvc = [[GKTurnBasedMatchmakerViewController alloc] initWithMatchRequest:request]; mmvc.turnBasedMatchmakerDelegate = self; mmvc.showExistingMatches = YES; [presentingViewController presentViewController:

Categories : Osx

turn-on-rdebug-track-mode shows wrong line number in emacs
I can't claim to understand elisp or emacs functions particularly well, but I had the same problem (and some other issues too), and worked out a hack in this commit of my fork of ruby-debug-extra. The patch just adjusts the lineno variable by one: --- a/emacs/rdebug-track.el +++ b/emacs/rdebug-track.el @@ -212,8 +212,8 @@ problem as best as we can determine." "line number cue not found" ;;else (let* ((filename (match-string rdebug-marker-regexp-file-group block-str)) - (lineno (string-to-number - (match-string rdebug-marker-regexp-line-group block-str))) + (lineno (- (string-to-number + (match-string rdebug-marker-regexp-line-group block-str)) 1))

Categories : Ruby

Average number of bits required to store one letter of British English using perfect compression in python
The page you link to again links to this page: Refining the Estimated Entropy of English by Shannon Game Simulation If you read carefully, the entropy computed there is not naively computed using the probability of occurrences for each letters - instead, it is computed by The subject was shown the previous 100 characters of text and asked to guess the next character until successful So I think you are not wrong, only the method you use differ - using only naive occurrence probability data, you cannot compress the information that well, but if you take the context into consideration, then there are so much more the redundant information. E.g., e has a probability of 0.127, but for th_, e probably has something more like 0.3.

Categories : Python

How can I get sets of 2 entries where each set starts with a different letter and no letter is repeated from a sqlite database?
You can do this with the substr function and a correlated subquery: SELECT * FROM YourTable a WHERE wordField IN (SELECT wordField FROM YourTable AS b WHERE substr(a.wordField ,1,1) = substr(b.wordField ,1,1) ORDER BY wordField LIMIT 2) Demo: SQL Fiddle You can use the ORDER BY to adjust which 2 records are returned. Like ORDER BY RANDOM() if that's supported.

Categories : SQL

At the moment when I click on keyboard letter, it appears in EditText1, next letter in EditText2
Set a counter at Action_down event tracking function. If counter is 1, then set it like editText1.setText("keypressed"); if counter is 2 then, editText2.setText("keypressed"); etc.. Sice we can add strings dynamically to editText this must work! have a try dude!

Categories : Android

Populate country list with respective two letter and three letter code in c#
If you really must retrieve this information using C#, this is how I'd do it: var regions = CultureInfo.GetCultures(CultureTypes.AllCultures) .Where(c => !c.IsNeutralCulture && c.LCID != 0x7f) .Select(c => new RegionInfo(c.LCID)) .GroupBy(r => r.TwoLetterISORegionName) // This is an alternative to using Distinct .Select(g => g.First()) // It's probably not very efficient, but the list is so small anyway. .OrderBy(r => r.TwoLetterISORegionName) .ToList(); (The culture with the LCID 0x7f is the InvariantCulture, which doesn't have an associated RegionInfo.) This gives only 127 countries on my computer. Your method gives a lot more results because there are many instances of multiple CultureInfos that share the same RegionInfo

Categories : C#

Changing letter typed by Keyboard by other letter and show it in UITexfield
Yes, use method – textField:shouldChangeCharactersInRange:replacementString: in UITextFieldDelegate. f.e. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSString* encodedString = [self encode:string]; textField.text = [textField.text stringByReplacingCharactersInRange:range withString: encodedString]; self.decodedTextField.text = [self.decodedTextField.text stringByReplacingCharactersInRange:range withString:string]; return NO; } it is just example, you should implement replacement more careful.

Categories : IOS

Matching number of rows in one excel table with the number of rows in another
It sounds like you can possibly do this manually with autofill, but if you wish to use a macro something like this could get you started: Sub Macro1() ' put your function here Range("B1").FormulaR1C1 = "=RC[-1]*2" Dim dest As Integer dest = Range("A1").End(xlDown).Row Range("B1").AutoFill Destination:=Range("B1:B" & dest), Type:= _ xlFillDefault End Sub This will autofill a function in column B to as much data is contained in column A. Now you stated that you need to "expand or compress the rows to match the imported data." You can do this by clearing the B column at the beginning of the macro. Hopefully this helps, if this is confusing or does not help your problem let me know.

Categories : Excel

Search & replace row by row, letter by letter in table using Python
A little fuzzy on some of your details but it appears the code is attempting to compare a Field data object (created w/for r in row) with the elements in some input set, which you seem to imply is a string. Aside from the type mismatch of Field vs string, I believe that a Row object is not iterable the way you've written it. You can get the fields with something like: fldList = list() for fld in arcpy.ListFields(r'C:Workspacesomedata.shp'): fldList.append(fld.name) and then iterate of fldList using something like: for fld in fldList: fldValue = row.getValue(fld) ....do some regex/string parsing ....if condition met, use row.setValue(fld, newValue) and rows.update(row)

Categories : Python

Select value only with letter is starting letter in autocomplete datalist
Use source option to implement your own search: var dataSource = ['mary', 'reeta', 'james']; $("input").autocomplete({ minLength: 1, source: function(request, response) { var matcher = new RegExp( '^' + $.ui.autocomplete.escapeRegex(request.term), "i" ); var filteredData = $.grep( dataSource, function(value) { return matcher.test( value.label || value.value || value ); }); response(filteredData); } }); example http://jsfiddle.net/AU92X/8/ Or you can even make it global just by rewriting $.ui.autocomplete.escapeRegex: var dataSource = ['mary', 'reeta', 'james']; $("input").autocomplete({ minLength: 1, source: dataSource }); var escapeRegexp = $.ui.autocomplete.escapeRegex; $.extend( $.ui.autocomplete, { escapeRegex

Categories : HTML

asp.net pdf linking; page number not matching
you need to subtract one from the number that you want. the array starts at 0. have you checked this in all the other browsers? Internet Explorer might be the only one that doesn't do it like this, but I am thinking that it is in the way that the PDF Viewer works and not the browser. Update subtract 1 from the page number you want. that is how the pdf viewer is set up, pretty sure that there are going to be a lot of them like that. if that is the most common pdf Viewer then that should be your standard. Checking for Browser here is a page that runs through a JavaScript to find the Browser that the user is using. you will probably have to adapt it so that you can change your link based on what browser is being used. Browser Detect in Javascript

Categories : C#

Matching words that end in any number of digits OR "X"
Try using a non-greedy match (adding a ? after w+) to consume as little as possible and still match: {_(w+?)(d+|X)} or if your language (unspecified) supports look-arounds, then: {_(w+)(?<=[a-zA-Z])(d+|X)} which asserts that the last character of group 1 must be a letter (although letters may appear elsewhere within group 1)

Categories : Regex

Matching keynum to an array index number?
function keypress() { var buttons = []; for (var i = 65; i <= 90; i++) { buttons[i] = buttons[i + 32] = document.getElementById(String.fromCharCode(i + 32)); } var keynum = (window.event) ? event.keyCode : e.which; if (buttons[keynum]) { buttons[keynum].style.backgroundColor = 'red'; } } You were comparing buttons[i] with keynum. But buttons[i] contains a document element, not a number. You just want to use keynum as the index into the buttons array. I changed the buttons array to have entries for both upper and lowercase letters, and used a loop to fill it in. You only had entries for uppercase, so you had to press Shift to make anything happen. FIDDLE

Categories : Javascript

SED word ending with a letter and deleting that letter
This will work: sed -e '/s$/!d' -e 's/s$//' Or this: sed '/s$/!d;s/s$//' Or this: sed -n '/s$/{s/s$//;p;}'

Categories : Unix

Why the capital letter is greater than small letter in .Net?
The doc I could find says that: This method performs a word (case-sensitive and culture-sensitive) comparison using the current culture. So, it is not quite the same as Java's .compareTo() which does a lexicographical comparison by default, using Unicode code points, as you say. Therefore, in .NET, it depends on your current "culture" (Java would call this a "locale", I guess). It seems that if you want to do String comparison "à la Java" in .NET, you must use String.CompareOrdinal() instead. On the opposite, if you want to do locale-dependent string comparison in Java, you need to use a Collator. Lastly, another link on MSDN shows the influence of cultures on comparisons and even string equality.

Categories : C#

How to turn silent mode on during a specific time period in Android? and turn back to normal after the whole duration?
You can use the android FrameWork class AudioManager as follow : AudioManager manager = (AudioManager)getSystemService(AUDIO_SERVICE); manager.setRingerMode(AudioManager.RINGER_MODE_SILENT); Hope it helps :)

Categories : Android

Regex for number matching optional with whitespace and character?
[O0-9 ]{19} (there is a space between the [O0-9 and the ]) example http://regexr.com?35r1c Probably it's better to anchor at the beginning and end of the string ^[O0-9 ]{19}$ example http://regexr.com?35r1f

Categories : Regex

python: number range to regex matching string
[assuming you need this because it's some weird 3rd party system that requires regexp] New Approach the more i think about Frederik's comment, the more i agree. the regexp engine should be able to compile this down to a compact DFA, even if the input string is long. for many cases, the following is a sensible solution: import re def regexp(lo, hi): fmt = '%%0%dd' % len(str(hi)) return re.compile('(%s)' % '|'.join(fmt % i for i in range(lo, hi+1))) (it works fine with all the numerical ranges in the tests below, including 99519000 - 99519099. a rough back-of-the-envelope calculation suggests that 9 digit numbers are about the limit with 1GB of memory. that's if most numbers that size are matched; if only a few are matched you can go much larger.). Old Approach [updated a

Categories : Python

Haskell Pattern Matching Fails on Negative Number
It fails because it thinks you're trying to re-define the minus operator, because f -1 = ... gets parsed as f - 1 = .... To fix this you just have to add parentheses: balancedMax :: Int -> Int -> Int balancedMax (-1) _ = -1 balancedMax _ (-1) = -1 balancedMax a b = max a b The same thing happens in expressions. To call balancedMax with a negative literal, you would need parentheses as well.

Categories : Function

.NET Regex to back capture only the number from a matching group
I do not think this is possible - here's a question that seems to be exactly the same thing you're asking for: Regex Pattern Matching Concatenation

Categories : Dotnet

print specific number of lines after matching pattern
There is a pretty straightforward way to do this with grep: grep -A 81 AAA input_file From the man page: -A NUM, --after-context=NUM Print NUM lines of trailing context after matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given.

Categories : Regex

In regular expression matching of Perl, is it possible to know number of matches in a{n,}
If you have a pattern of type /AB{n,}/ where A and B are complex patterns, we can split the regex into multiple pieces: my $string = "ABABBBB"; my $n = 3; my $count = 0; TRY: while ($string =~ /A/gc) { my $pos = pos $string; # remember position for manual backtracking $count++ while $string =~ /GB/g; if ($count < $n) { $count = 0; pos($string) = $pos; # restore previous position } else { last TRY; } } say $count; Output: 4 However, embedding code into the regex to do the counting may be more desirable, as it is more general: my $string = "ABABBBB"; my $count; $string =~ /A(?{ $count = 0 })(?:B(?{ $count++ })){3,}/ and say $count; Output: 4. The downside is that this code won't run on older perls. (Code was tested on v14 & v16). Edit: The first solut

Categories : Regex



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