String string = "Madam, I am Adam";
// Starts with
boolean b = string.startsWith("Mad");
// true
// Ends with
b = string.endsWith("dam");
// true
// Anywhere
b = string.indexOf("I am") > 0;
// true
// To ignore case, regular expressions must be used
// Starts with
b = string.matches("(?i)mad.*");
// Ends with
b = string.matches("(?i).*adam");
// Anywhere
b = string.matches("(?i).*i am.*");
//
.replaceAll("\\W", ""); replace all non-alphanumerics
Tuesday, August 3, 2010
Monday, July 26, 2010
Auto Incrementing primary key with Oracle
SQL> CREATE TABLE test
(id NUMBER PRIMARY KEY,
name VARCHAR2(30));
Table created.
SQL> CREATE SEQUENCE test_sequence
START WITH 1
INCREMENT BY 1;
Sequence created.
Now we can use that sequence in an BEFORE INSERT trigger on the table.
CREATE OR REPLACE TRIGGER test_trigger
BEFORE INSERT
ON test
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT test_sequence.nextval INTO :NEW.ID FROM dual;
END;
Trigger created.
Wednesday, July 21, 2010
JSTL [S]crap
Iterating ArrayList of Arrays
<c:foreach items="${list}" var="innerList">
<c:foreach items="${innerList}" var="item">
<c:out value="${item}"></c:out>|
</c:foreach> <br>
</c:foreach>
<c:foreach items="${list}" var="innerList">
<c:foreach items="${innerList}" var="item">
<c:out value="${item}"></c:out>|
</c:foreach> <br>
</c:foreach>
Wednesday, February 10, 2010
MySql Tips
Loading data from a text file :
Removing spaces :
LOAD DATA INFILE 'aino.txt' INTO TABLE products_options_values (products_options_values_name);(Text file is read from the database directory of the default database)
Removing spaces :
update products_options_values set products_options_values_name = REPLACE(products_options_values_name,' ' ,'');
Labels:
MYSQL
Subscribe to:
Posts (Atom)

