End of line anchor $ match even there is extra trailing \n in matched string, so we use \Z instead of $
For example
^\w+$ will match the string abcd\n but ^\w+\Z is not
How about \A and when to use?
I have XAML similar to this:
<ListBox ItemsSource="{Binding SearchCriteria, Source={StaticResource model}}" SelectionChanged="cboSearchCriterionType_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Name="spCriterion" Orientation="Horizontal" Height="20">
<ComboBox Name="cboSearchCriterionType" Width="120" SelectionChanged="cboSearchCriterionType_SelectionChanged">
<ComboBox.Items>
<ComboBoxItem IsSelected="True" Content="Anagram Match" />
<ComboBoxItem Content="Pattern Match" />
<ComboBoxItem Content="Subanagram Match" />
<ComboBoxItem Content="Length" />
<ComboBoxItem Content="Number of Vowels" />
<ComboBoxItem Content="Number of Anagrams" />
<ComboBoxItem Content="Number of Unique Letters" />
</ComboBox.Items>
</ComboBox>
<TextBox x:Name="SearchSpec" Text="{Binding SearchSpec}" />
<TextBox x:Name="MinValue" Text="{Binding MinValue}" Visibility="Collapsed" />
<TextBox x:Name="MaxValue" Text="{Binding MaxValue}" Visibility="Collapsed" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
As you can tell from the markup, I have a listbox that is bound to a collection of SearchCriterion objects (collectively contained in a SearchCriteria object). The idea is that the user can add/remove criterion items from the criteria, each criterion is represented by a listbox item. Inside the listbox item I have a combobox and three textboxes. What I'm trying to do is change the visibility of the TextBox controls depending on the item that is selected in the ComboBox. For example, if the user selects "Pattern Match" then I want to show only the first textbox and hide the latter two; conversely, if the user selects "Length" or any of the "Number of..." items, then I want to hide the first TextBox and show the latter two.
What is the best way to achieve this? I was hoping to do something simple in the SelectionChanged event handler for the listbox but the textbox controls are presumably out of the SelectionChanged event's scope. Do I have to programmatically traverse the control hierarchy and find the controls?
I am close but I am not sure what to do with the restuling match object. If I do
p = re.search('[/@.* /]', str)
I'll get any words that start with @ and end up with a space. This is what I want. However this returns a Match object that I dont' know what to do with. What's the most computationally efficient way of finding and returning a string which is prefixed with a @?
For example,
"Hi there @guy"
After doing the proper calculations, I would be returned
guy
I'm parsing some code and want to match the doxygen comments before a function. However, because I want to match for a specific function name, getting only the immediately previous comment is giving me problems.
Is there a way to search backward through a string using the Python Regex library?
Is there a better (easier) approach that I'm missing?
The following code is making my app crash at line 3 without an error I would recognize or know how to deal with. Any ideas as to what I am doing wrong?
NSInteger *match = [str1 intValue] + [str2 intValue];
NSString *strrep = [NSString stringWithFormat:@"%i", match];
label.text = [strrep substringWithRange:NSMakeRange(1,3)];
I just found out my host is on ZEUS..
Please can somebody help me with my rewrites:
domain.com/001234
redirects to
domain.com/001234-some-keywords.html
Apache:
RewriteRule ^([0-9]{6}+)/?$ includes/redirect.php?ref=$1 [L]
RewriteRule ^([0-9]{6})-.*?\.html$ templates/default/index.php?ref=$1 [L]
tried this in Zeus:
match URL into $ with ^([0-9]{6}+)/?$
if matched then
set URL = includes/redirect.php?ref=$1
endif
match URL into $ with ^id/([0-9]+)/?$
if matched then
set URL = home/content.php?id=$1
endif
Hi everyone...
I'd asked a question about the splitting the a string like below:
Input string: "a=aa| b=b||b | c=cc"
and the output:
a=aa
b=b||b
c=cc
Kobi's answer was:
var matches = "a=aa|b=b||b|c=cc".match(/(?:[^|]|\|\|)+/g)
his answer was correct.
But I need to use "split" method and save store the outputs in a array.
so I can't use the Match Method.
So please help me...
svn diff -rXX:HEAD
Will give me a format like this, if there has been a merge between those revisions:
Merged /<branch>:rXXX,XXX-XXX
or
Merged /<branch>:rXXX
I'm not very familiar with regex and am trying to put together a pattern which will match all the numbers (merged revision numbers) AFTER matching the "Merged /branch:r" part.
So far I have this to match the first part:
[Mm]erged.*[a-zA-Z]:r
Thanks in adv. for the help :)
For example,
val list = List(1,2,3)
list match{
case a:::b =>
case _ =>
}
you can match head and tail of a List using :::' or tokens of ParseResult using~'. What should I do to create class that can be matched like preceding classes?
I want to add a WHERE clause to a full text search query (to limit to past 24 hours), but wherever I insert it I get Low Level Error. Is it possible to add the clause and if so, how? Here is the code WITHOUT the where clause:
$query = "SELECT *, MATCH (story_title) AGAINST ('$query' IN BOOLEAN MODE)
AS Relevance FROM stories WHERE MATCH (story_title) AGAINST ('+$query' IN BOOLEAN MODE)
HAVING Relevance > 0.2 ORDER BY Relevance DESC, story_time DESC;
I want to create a Rails 3 route with entirely optional parameters. The example route is:
match '(/name/:name)(/height/:height)(/weight/:weight)' => 'people#index'
The route works if I specify it as:
match '/people(/name/:name)(/height/:height)(/weight/:weight)' => 'people#index'
But I want to have this as the root URL. Thanks.
I am new to PHP and regular expression. I was going thorugh some online examples and came with this example:
<?php
echo preg_replace_callback('~-([a-z])~', function ($match) {
return strtoupper($match[1]);
}, 'hello-world');
// outputs helloWorld
?>
in php.net but to my surprise it does not work and keep getting error:
PHP Parse error: parse error, unexpected T_FUNCTION
Why get error ?
Hi,
I have this code, it looks alright and is really basic, but i can't make it work:
function checkValid(elem){
var abc = elem.value;
var re = "/[0-9]/";
var match = re.test(abc);
alert(match);
}
It matches 0 and 9, but not 1 to 8, what's wrong here? Thanks.
Hey all, i want to use a regular expression to match a word with one specified character randomly placed within it. I also want to keep that 'base' word's characters in their original order.
For example, with the 'base' word of test and the specified character of 'y', i want the regular expression to match all the following, and ONLY the following: ytest, tyest, teyst, tesyt, testy
Incase it matters, im working in javascript and using the dojo toolkit.
Thanks!
End of line anchor $ match even there is extra trailing \n in matched string, so we use \Z instead of $
For example
^\w+$ will match the string abcd\n but ^\w+\Z is not
How about \A and when to use?
How to combine these two sql queries into one?
SELECT DISTINCT * FROM rss WHERE MATCH(content,title) AGAINST ('$filter')
SELECT COUNT(content) FROM rss WHERE MATCH(content,title) AGAINST ('$filters')
And if the result is 0 from the above query
-
SELECT DISTINCT * FROM rss WHERE content LIKE '%$filters%' OR title LIKE '%$filters%';
$filter .= $row['filter'];
$filters = $row['filter'];
$filters may be more than one keyword
I have a page that needs to create dynamic form fields as often as the user needs, and I am trying to use Ajax to tie it in to my database for faster form entry and to prevent user typos.
So, I have put my Ajax returned data into popup div, the user selects, then the form field is filled in. The problem comes on the cloned fields. They don't seem to want to bring up the popup div when focused. I am thinking it is something to do with when they get created/added to the DOM.
Here is my JS that creates the clones:
$(document).ready(function() {
var regex = /^(.*)(\d)+$/i;
var cloneIndex = $(".clonedInput").length;
$("button.clone").live("click", function(){
$(this).parents(".clonedInput").clone()
.appendTo("#course_container")
.attr("id", "clonedInput" + cloneIndex)
.find("*").each(function() {
var id = this.id || "";
var match = id.match(regex) || [];
if (match.length == 3) {
this.id = match[1] + (cloneIndex);
}
});
cloneIndex++;
numClones=cloneIndex-1;
//alert("numClones "+numClones);
});
Here is where I expect to be able to get focus on the correct cloned field and call the popup. The baker_equiv0 id is original code, whereas baker_equiv1 is the first clone.
$('#baker_equiv0').focus(function() { \\ THIS CODE WORKS
$('.popup').fadeIn(500);
$('#results').empty();
// document.enter_data.baker_equiv1.value="test"; THIS LINE WORKS
//alert("numClones "+numClones);
});
$('#baker_equiv1').focus(function() { // THIS DOESN'T EVER FIRE
alert("numClones "+numClones);
$('.popup').fadeIn(500);
$('#results').empty();
});
Here is the HTML with the form:
<label for="baker_equiv" class="">Baker Equivalent: <span class="requiredField">*</span></label>
<input type="text" class="cinputsa" name="baker_equiv[]" id="baker_equiv0" size="8" ONKEYUP="get_equiv(this.value);">
If I put this in the HTML code above, it works fine: onfocus="alert(this.id)"
I'd also be interested in how to adjust the JS code to work based on the id array created rather than having to copy code for each potential set of fields clones, i.e., baker_equiv[] rather than baker_equiv0, baker_equiv1, etc.
Thanks all!
I am trying to fumble through python, and learn the best way to do things. I have a string where I am doing a compare with another string to see if there is a match:
if paid[j].find(d)>=0:
#BLAH BLAH
If 'd' were an array, what is the most efficient way to see if the string contained in paid[j] has a match to any value in 'd'?
I need a regular expression that matches three consecutive characters (any alphanumeric character) in a string.
Where 2a82a9e4eee646448db00e3fccabd8c7 "eee" would be a match.
Where 2a82a9e4efe64644448db00e3fccabd8c7 "444" would be a match.
etc.
This line:
used_emails = [row.email for row
in db.execute(select([halo4.c.email], halo4.c.email!=''))]
Returns:
['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
I use this to find a match:
if recipient in used_emails:
If it finds a match I need to pull another field (halo4.c.code) from the database in the same row. Any suggestions on how to do this?
I have a url which looks like this
https://test.high.com/people/11111111-name-firstname-_custa/deals/new
Now i need to match document.URL
if im on that Page if so i will alert a message.
The important part is /deals/new
How can i match that in Javascript?
Hello, I am trying to use RE to match a changing ID and extract it. I am having some bother getting it working. The String is:
m = 'Some Text That exists version 1.0.41.476 Fri Jun 4 16:50:56 EDT 2010'
The code I have tried so far is:
r = re.compile(r'(s*\s*)(\S+)')
m = m.match(r)
Can anyone help extract this string.
Thanks
I am reading a file that sometimes has chinese and characters of languages other than english.
How can I write a regex that only reads english words/letters?
should it just be /^[a-zA-Z]+/ ?
If I do the above then words like eété will still be picked but I don't want them to be picked:
"été".match(/^[a-zA-Z]+/) => #nil good I didnt want that word
"eété".match(/^[a-zA-Z]+/) => #not nil tricked into picking something i did not want
I'm looking for a much more idiomatic way to do the following little ruby script.
File.open("channels.xml").each do |line|
if line.match('(mms:\/\/{1}[a-zA-Z\.\d\/\w-]+)')
puts line.match('(mms:\/\/{1}[a-zA-Z\.\d\/\w-]+)')
end
end
Thanks in advance for any suggestions.
I have this regexp:
/(.*)(([0-9]([^a-zA-Z])*){7,}[0-9])(.*)/.
Given the following values
0654535263
065453-.-5263
065asd4535263
Expected Results
06****
06****
06****
Actual Results
0654535263
06****
065asd4535263
It does not match the last row because of the letters (I want to match from 0-3 letters) and it matches only last occurence (in the second row in example, it skips first row).