Hi. Since I'm finding this site helpful I thought I'd sign up :)
I need to get the stock values out of this array:
Array (
[stock0] => 1
[stockdate0] =>
[stock1] => 3
[stockdate1] => apple
[stock2] => 2 [
stockdate2] =>
)
I need to pattern match on this array, where the array key = "stock" + 1 wildcard character.
I have tried us...
Let's say I want to make a special case for a function that matches strings that start with the character 'Z'. I could easily do it using pattern matching by doing something like the following:
myfunc ('Z' : restOfString) = -- do something special
myfunc s = -- do the default case here
But what if I want to match strings with a longer...
Hi all,
Is there a multiple instances pattern in F# somewhere?
Consider that I'm working on a list. I have the following pattern matching
match l with
| [] | [_] -> l //if the list is empty or contains only one item, simply return it
|
//is there a pattern to test if all of the elements are identical?
In other words p...
Hi i would like to have a regex in php which matches a word in a string but if the word is a link.
The problem is that I replace words with links for example:
"text" => < a href = "mylink">text< /a>.
But sometimes I have the problem that it is replaced twice. So I want to avoid this problem.
My pattern now is /text/i.
Eg.
This is my...
Hi,
I am looking for a regular expression in PHP which would match the anchor with a specific text on it. E.g I would like to get anchors with text mylink like:
<a href="blabla" ... >mylink</a>
So it should match all anchors but only if they contain specific text So it should match these strings:
<a href="blabla" ... >mylink</a>
<a ...
Hi all,
Intro
I work in a facility where we have microscopes. These guys can be asked to generate 4D movies of a sample: they take e.g. 10 pictures at different Z position, then wait a certain amount of time (next timepoint) and take 10 slices again.
They can be asked to save a file for each slice, and they use an explicit naming pat...
Hi, is there a possibility to match in a function definition do some subset of a touple and still get get complete touple in the method ?
What I would like to do is something like this:
myfun({ foo, Bar }: Var) -> otherfunction(Var, stuff).
instead of:
myfun({ foo, Bar }) -> otherfunction({ foo, Bar }, stuff).
I hope this is clear...
I need to extract the virtual host name of a HTTP request.
Since this willl be done for every request, I´m searching for the fastest way to do this.
The following code and times are just some of the ways I had studied.
So, there is some faster way to do this?
$hostname = "alphabeta.gama.com";
$iteractions = 100000;
//While Test
$ti...
As part of a project I have assigned myself as a way of improving my knowledge of F# and functional programming in general, I am attempting to write a string pattern-matching algorithm from scratch without using any loops or variables (or regular expressions, or String.Replace and friends). As this is purely a learning project, I'm not i...
Assume I have such folders
rootfolder
|
/ \ \
01 02 03 ....
|
13_itemname.xml
So under my rootfolder, each directory represents a month like 01 02 03 and under these directories I have items with their create hour and item name
such as 16_item1.xml, 24_item1.xml etc, as you may guess there are several items an...
I need a very specific function in PHP. Basically, I have two strings as arguments, one of which is a pattern that contains wildcards of variable length (*), and one of which is a string that matches that pattern. I need to get an array of the strings from the latter string that fill in the wildcards in the pattern.
For example:
Arg...
In the following Haskell code, how can this be written more succinctly? Is it necessary to list all four conditions, or can these be summarized by a more compact pattern? For instance, is there a way I can take advantage of Haskell already knowing how to add a float and an int, without having to manually specify fromIntegral?
data Sig...
This page has a great example using REGEXP to do pattern matching. the problem with REGEXP won't match the following strings:
"Mr John"
"Dr. John"
or even:
"Mr. John Doe"
with the string "John Doe"
I would like to know how do I get positive matches for any of the given examples?
Here is a sample code:
Drop table Names;
CREATE ...
I seem to remember an older version of F# allowing structural decomposition when matching sequences just like lists. Is there a way to use the list syntax while keeping the sequence lazy? I'm hoping to avoid a lot of calls to Seq.head and Seq.skip 1.
I'm hoping for something like:
let decomposable (xs:seq<'a>) =
match xs with
|...
Hi all,
I am using the following code to remove both leading and tailing spaces from all lines of a file A.txt
sed 's/^[ \t]*//;s/[ \t]*$//' ./A.txt > ./B.txt
The problem occurs on the lines where there is a t in the beginning or at the end. So say for example, the original line that starts with the string "timezone" becomes "imezon...
I need a pattern that will traverse the document and get me all links that have mailto in their href:
<a href="mailto:[email protected]">text</a>
I could of course easily get all a elements ($("a")) and check each href attribute to see if it points to a mailto but I think that jQuery has some form of pattern matching that will allow me to ...
Hi all,
I am tasked with white labeling an application so that it contains no references to our company, website, etc. The problem I am running into is that I have many different patterns to look for and would like to guarantee that all patterns are removed. Since the application was not developed in-house (entirely) we cannot simply ...
Hi
I'm looking for a way of pattern matching the "geometry" of an array, the order in which the elements appear, not the contents of each element directly.
Let me outline what I mean by some examples. Given the target array:
array('T_STRING','T_VARIABLE','ASSIGN','T_STRING','LPAREN','T_VARIABLE','COMMA','T_VARIABLE','RPAREN');
//as a ...
I'm a Scala beginner and this piece of code makes me struggle.
Is there a way to do pattern matching to make sure everything i pass to Data is of the correct type? As you can see i have quite strange datatypes...
class Data (
val recipient: String,
val templateText: String,
val templateHtml: String,
val blockMaps: Map[String,List[Ma...
Hello everyone there...
I have a problem, suppose I have a given string: "best", the target string is suppose: "beast". Then I have to determine the number of operations to convert the given string to the target string, however the operations allowed are:
1. add a character to string.
2. delete a character.
3. swap two char positions. (...