regular expression to match a U.S. phone number:
\(?\d{3}\)? ?\d{3}[-.]\d{4}
This regex matches phone numbers like "(314)555-4000".
Ask yourself if the regex would match "314-555-4000" or "555-4000".
The answer is no in both cases. Writing this pattern on one line
conceals both flaws and design decisions. The area code is
required and the regex fails to account for a separator
between the area code and prefix.
/
\(? # optional parentheses
\d{3} # area code required
\)? # optional parentheses
[-\s.]? # separator is either a dash, a space, or a period.
\d{3} # 3-digit prefix
[-.] # another separator
\d{4} # 4-digit line number
/x
replace all instances of double quotes with
single - /g option is all instances
replace(/\"/g,'\'')
Monday, 11 September 2006
Friday, 25 August 2006
TSQL: Joins with 3 tables
--T-SQL with 3 tables
--Now we take a table more between A and C (it's simple in T-SQL):
update A
set A.a2 = c.c2
from A
inner join B on A.a1 = B.b1
inner join C on B.b2 = c.c1
--Now we take a table more between A and C (it's simple in T-SQL):
update A
set A.a2 = c.c2
from A
inner join B on A.a1 = B.b1
inner join C on B.b2 = c.c1
Saturday, 15 July 2006
CSS: XP bug - background image on buttons not displaying
if the background button image doesn't display:
use "background" instead of "background-image", its an xp bug!!
http://support.microsoft.com/kb/322240
<INPUT TYPE="button" style="background:url(/_Images/mms/bt_reset.gif); border:none; height:20px; width:77px;">
use "background" instead of "background-image", its an xp bug!!
http://support.microsoft.com/kb/322240
<INPUT TYPE="button" style="background:url(/_Images/mms/bt_reset.gif); border:none; height:20px; width:77px;">
Monday, 29 May 2006
TSQL: UPDATE
UPDATE
{
table_name WITH ( <table_hint_limited> [...n])
| view_name
| rowset_function_limited
}
SET
{column_name = {expression | DEFAULT | NULL}
| @variable = expression
| @variable = column = expression } [,...n]
{{[FROM {<table_source>} [,...n] ]
[WHERE
<search_condition>] }
|
[WHERE CURRENT OF
{ { [GLOBAL] cursor_name } | cursor_variable_name}
] }
[OPTION (<query_hint> [,...n] )]
UPDATE authors
SET authors.au_fname = 'Annie'
WHERE au_fname = 'Anne'
UPDATE titles
SET ytd_sales = t.ytd_sales + s.qty
FROM titles t, sales s
WHERE t.title_id = s.title_id
AND s.ord_date = (SELECT MAX(sales.ord_date) FROM sales)
{
table_name WITH ( <table_hint_limited> [...n])
| view_name
| rowset_function_limited
}
SET
{column_name = {expression | DEFAULT | NULL}
| @variable = expression
| @variable = column = expression } [,...n]
{{[FROM {<table_source>} [,...n] ]
[WHERE
<search_condition>] }
|
[WHERE CURRENT OF
{ { [GLOBAL] cursor_name } | cursor_variable_name}
] }
[OPTION (<query_hint> [,...n] )]
UPDATE authors
SET authors.au_fname = 'Annie'
WHERE au_fname = 'Anne'
UPDATE titles
SET ytd_sales = t.ytd_sales + s.qty
FROM titles t, sales s
WHERE t.title_id = s.title_id
AND s.ord_date = (SELECT MAX(sales.ord_date) FROM sales)
TSQL: INSERT
INSERT [INTO]
{
table_name WITH ( <table_hint_limited> [...n])
| view_name
| rowset_function_limited
}
{ [(column_list)]
{ VALUES ( { DEFAULT
| NULL
| expression
}[,...n]
)
| derived_table
| execute_statement
}
}
| DEFAULT VALUES
<table_hint_limited> ::=
{ INDEX(index_val [,...n])
| FASTFIRSTROW
| HOLDLOCK
| PAGLOCK
| READCOMMITTED
| REPEATABLEREAD
| ROWLOCK
| SERIALIZABLE
| TABLOCK
| TABLOCKX
}
INSERT INTO TENANTS..ADDRESS (ADDRESS) VALUES ('129 GABBA ROAD, WOOLLOONGABBA')
{
table_name WITH ( <table_hint_limited> [...n])
| view_name
| rowset_function_limited
}
{ [(column_list)]
{ VALUES ( { DEFAULT
| NULL
| expression
}[,...n]
)
| derived_table
| execute_statement
}
}
| DEFAULT VALUES
<table_hint_limited> ::=
{ INDEX(index_val [,...n])
| FASTFIRSTROW
| HOLDLOCK
| PAGLOCK
| READCOMMITTED
| REPEATABLEREAD
| ROWLOCK
| SERIALIZABLE
| TABLOCK
| TABLOCKX
}
INSERT INTO TENANTS..ADDRESS (ADDRESS) VALUES ('129 GABBA ROAD, WOOLLOONGABBA')
Monday, 13 February 2006
TSQL: CASE example
SELECT
FirstName, LastName,
Salary, DOB,
CASE Gender
WHEN 'M' THEN 'Male'
WHEN 'F' THEN 'Female'
END
FROM Employees
FirstName, LastName,
Salary, DOB,
CASE Gender
WHEN 'M' THEN 'Male'
WHEN 'F' THEN 'Female'
END
FROM Employees
Sunday, 15 January 2006
TSQL: Joins, INNER, OUTER and upsidedown!
An inner join excludes rows from either table that don't have a matching row in the other table. An outer join provides the ability to include unmatched rows in the query results. The outer join combines the unmatched row in one of the tables with an artificial row for the other table. This artificial row has all columns set to null.
The outer join is specified in the FROM clause and has the following general format:
table-1 { LEFT | RIGHT | FULL } OUTER JOIN table-2 ON predicate-1
predicate-1 is a join predicate for the outer join. It can only reference columns from the joined tables. The LEFT, RIGHT or FULL specifiers give the type of join:
LEFT -- only unmatched rows from the left side table (table-1) are retained
RIGHT -- only unmatched rows from the right side table (table-2) are retained
FULL -- unmatched rows from both tables (table-1 and table-2) are retained
The outer join is specified in the FROM clause and has the following general format:
table-1 { LEFT | RIGHT | FULL } OUTER JOIN table-2 ON predicate-1
predicate-1 is a join predicate for the outer join. It can only reference columns from the joined tables. The LEFT, RIGHT or FULL specifiers give the type of join:
LEFT -- only unmatched rows from the left side table (table-1) are retained
RIGHT -- only unmatched rows from the right side table (table-2) are retained
FULL -- unmatched rows from both tables (table-1 and table-2) are retained
Friday, 30 January 2004
Misc: Lorem Ipsum generator
http://www.lipsum.com/
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Subscribe to:
Posts (Atom)