Hi,
why this code does not work, and how to make it work?
let id1 = 0
match p1, p2 with
| Fluid, Particle id2 when id = id2
| Interface _, Particle id2 when id = id2 -> doSomething()
...
So is it possible to have several when guards in pattern groups?
...
Ok, so I know this question has been asked in different forms several times, but I am having trouble with specific syntax. I have a large string which contains html snippets. I need to find every link tag that does not already have a target= attribute (so that I can add one as needed).
^((?!target).)* will give me text leading up to 't...
I have this weirdly formatted URL. I have to extract the contents in '()'.
Sample URL : http://sampleurl.com/(K(ThinkCode))/profile/view.aspx
If I can extract ThinkCode out of it, I will be a happy man! I am having a tough time with regexing special chars like '(' and '/'.
Any help is highly appreciated. Thanks much guys!
...
I'm trying to write a polymorphic function, which needs to do something slightly different depending on the type of the parameter. Is there any way that I can do a pattern match on the type of the object, using the builtin types? I'm thinking of something along these lines:
let to_string v =
match v with
| string -> v
| in...
scala> class A
defined class A
scala> class B
defined class B
scala> val a: A = new A
a: A = A@551510e8
scala> a match {
| case _: B => println("unlikely")
| case _ => println("no match")
| }
no match
In the example above shouldn't the compiler tell me that one of the cases can never match? A slightly more complicated...
Hi there,
I'm making an XMLParser for a Java program (I know there are good XMLParsers out there but I just want to do it).
I have a method called getAttributeValue(String xmlElement, String attribute) and am using regex to find a sequence of characters that have the attribute name plus
="any characters that aren't a double quote"
I...
Hi,
I have a pattern like this:: word1 word2 word3 .
After pattern matching (using Perl) with word1, i have to print 'word2' and 'word3' as mentioned above.
Is there any pattern system variables available to do this??. If not what are the ways available to do this ??
Can anyone help me.
Advance thanks
Senthil.
...
In Erlang, you are encouraged not to match patterns that you do not actually handle. For example:
case (anint rem 10) of
1 -> {ok, 10}
9 -> {ok, 25}
end;
is a style that is encouraged, with other possible results resulting in a badmatch result. This is consistant with the "let it crash" philosophy in Erlang.
On the other hand...
There is this index function in "Erlang Programming":
index(0, [X|_]) -> X;
index(N, [_|Xs]) when N>0 -> index(N-1, Xs)
Isn't the guard "when N>0" superfluous because of the pattern matching? Calling index(0, List) will never end up in the second clause so N will always be > 0. Or am I totally wrong here?
...
Hi , I did a search but I didn't found anything . I'm looking for a pattern that will search in an alpha-numeric string (with the exact length of 7) the letter "P" . This is what I came up with until now , why isn't working ?
$pattern = "/^[\wP]{7}$/";
Many thanks in advance
...
Is it possible to achieve in Lua?
local noSlashEnding = string.gsub("slash\\ending\\string\\", "\\|/$", "")
-- noSlashEnding should contain "slash\\ending\\string"
local noSlashEnding2 = string.gsub("slash/ending/string/", "\\|/$", "")
-- noSlashEnding2 should contain "slash/ending/string"
The point here is the no acceptance of logic...
I need to learn about 2D pattern searching algorithms. Tips and links greatly appreciated.
More to the point:
Given a matrix of M[m,n] with values in K
example
000000000000
000001000000
010100010010 = M, K = {0, 1}
010100010001
101111010111
and a matrix L[i, j] with values in K + {X} representing a "shape"
example, the shape of...
Hi,
I have a InsuranceDetails SQL table, one of the column is VIN whose type is varchar(20). Ideally this column should contain only Alphanumeric values (Upper case and lower case allowed) as you might know about a typical VIN number.
For some reason this field gets some garbage values during insert.
I need to write a query that will g...
Consider the following Scala case class:
case class WideLoad(a: String, b: Int, c: Float, d: ActorRef, e: Date)
Pattern matching allows me to extract one field and discard others, like so:
someVal match {
case WideLoad(_, _, _, d, _) => d ! SomeMessage(...)
}
What I would like to do, and what's more relevant when a case class h...
I have a string like this <name>sekar</name>. I want to split this string (i am using perl) and take out only sekar, and push it into an array while leaving other stuff.
I know how to push into an array, but struck with the splitting part.
Does any one have any idea of doing this?
...
I have the following string to split into a table using lua:
(the data is aligned with each other. I did not find out how to write format it like that on this site)
IP: 192.168.128.12
MAC: AF:3G:9F:c9:32:2E
Expires: Fri Aug 13 20:04:53 2010
Time Left: 11040 seconds
the result should be put into a table l...
Hi guys,
I have a bit of a problem categorizing points based on relative normals.
What I would like to do is use the information I got below to fit a simplified polygon to the points, with a bias towards 90 degree angles to an extent.
I have the rough (although not very accurate) normal lines for each point, but I'm not sure how to sepa...
I want the expression (x-x) to be simplified to 0.
type aexpr =
| CstI of int
| Var of string
| Add of aexpr * aexpr
| Sub of aexpr * aexpr
| Mul of aexpr * aexpr;;
let rec simplify expr =
match expr with
| Add(CstI(n1), CstI(n2)) ->CstI(n1 + n2)
| Sub(CstI(n1), CstI(n2)) ->CstI(n1 - n2)
| Mul(CstI(n1), CstI(n2)) ->CstI(n1 * n2)
| Add...
Hello I have a .NET Regex. (with ignore-case)
I want it to match
field_x_12
field_a_ABC
field_r_something
etc
My question is why the . operator doesn't work in this regex:
field_[.]_.*
yet this (equivalent basically) regex does work:
field_[a-z]_.*
Is there something I'm missing about the dot operator . ?
...
Resharper 5's new pattern matching seems very powerful, though it takes a bit of tinkering to work out how to use it.
For those who aren't familiar with this feature, it allows you to search for specific patterns within your code. Instances of such patterns may optionally be replaced with an alternative. In IntelliJ this was called st...