var1=length(some port)
I want to do replicate('0',var1) in expression transformation logic in informatica.
Use Informatica REPLACECHR() function (see http://forgetcode.com/Informatica/1816-REPLACECHR-Replace-characters-in-a-string-with-some-other-character-or-remove-them)
For a number field you could use TO_CHAR to convert it to a string and then use the resulting variable (lets call it v_out) to run the replace on i.e. REPLACECHR(1, v_out,'123456789', '0')
Related
I have data that looks like this:
A|B|CC|DD|EE|FF|GG
Is there any way I can parse the string to output values of the pipe separators? Can someone give me some examples?
e.g.
A is the value before the first pipe
B is the value before the second pipe
etc.
etc.
It's possible within Expression Transformation but very inconvenient. You need to use INSTR and SUBSTR functions as indicated by #Vikas.
What you can also try is Java Transformation or...
A trick: how about dumping this (i.e. the string along with some key value) to a file prior to processing the dataset. And then use an additional Source Qualifier with Column delimiter set to "|" to do all the dirty work for you? Then you can join it all back together using a Joiner Transformation and the key value dumped to the file.
You can use INSTR and SUBSTR combination or REG_ commands . Thanks !!
I'm extracting information from logs in hive with this sentences:
regexp_extract(values, "^(\\w{3} \\s?\\d+ \\d\\d:\\d\\d:\\d\\d \\w+-\\w+ \\w+:) (\\[)(\\d{2})(\\/)(\\w{3})(\\/)(\\d{4})(.*\\])",3)day,
regexp_extract(values, "^(\\w{3} \\s?\\d+ \\d\\d:\\d\\d:\\d\\d \\w+-\\w+ \\w+:) (\\[)(\\d{2})(\\/)(\\w{3})(\\/)(\\d{4})(.*\\])",5)month
I use the same regular expression for extract two fields in two different regex_extract call. It is possible to extract more than one field only executing regex_extract once?
Maybe not exactly what you are looking for, but if your really want to have one extraction that will give you multiple fields instead of one, this is what I found:
http://dev.bizo.com/2012/01/using-genericudfs-to-return-multiple.html
Note that for this solution you need to write a UDF with object inspectors, but see for yourself.
I have a bunch of sql statements updated by my team developers.
I intend to run a check before these statements are run against a db.
for example, check if a certain column is hardcoded instead of being fetched from the respective table (foreign key)
for example:
INSERT INTO [Term1] ([CreatedBy]
,[CreateUser]) values(1,'asdadad')
where 1 is hardcoded value.
Is there a regular expression that can extract all insert statements from the file so that they can be parse?
I tried with this expression http://regexlib.com/REDetails.aspx?regexp_id=1750 but it didnot work
You may need to run a multi-level regex on this. First parse the entire parameter string from the whole query, then parse each individual field from the paramter string that you previously got to get each one specifically ignoring all the other characters that may come up.
I am new to SAS formats.
Say I have a string in the form of NNN.xxx where NNN is a number in the format of z3. and xxx is just some text.
E.g.
001.NUL and 002.ABC
Now can I define a format, fff, such that b = put("&NNN..&xxx.",fff.); returns only the &xxx. part?
I know we can achieve this by using b = substr("&NNN..&xxx.",5,3); but I want to have a format so that I can simply assign the format to a variable and not have to create a new variable out of it.
Thanks in advance.
Probably the only way is to code your own custom character format using SAS/TOOLKIT. It will be much easier to create another variable as you do with substr().
As said, I think this can be achieved thru combination of custom defined formats along with SAS builtin character functions - i.e. CAT, CATX, CATS, CATT etc...
I write a mysql query
select * from table where name like '%salil%'
which works fine but it will no return records with name 'sal-il', 'sa#lil'.
So i want a query something like below
select * from table whereremove_special_character_from(name)like '%salil%'
remove_special_character_from(name) is a mysql method or a regular expression which remove all the special characters from name before like executed.
No, mysql doesn't support regexp based replace.
I'd suggest to use normalized versions of the search terms, stored in the separate fields.
So, at insert time you strip all non-alpha characters from the data and store it in the data_norm field for the future searches.
Since I know no way to do this, I'd use a "calculated column" for this, i.e. a column which depends on the value of name but without the special characters. This way, the cost for the transformation is paid only once and you can even create an index on the new column.
See this answer how to do this.
I agree with Aaron and Col. Shrapnel that you should use an extra column on the table e.g. search_name to store a normalised version of the name.
I noticed that this question was originally tagged ruby-on-rails. If this is part of a Rails application then you can use a before_save callback to set the value of this field.
In MYSQL 5.1 you can use REGEXP to do regular expression matching like this
SELECT * FROM foo WHERE bar REGEXP "baz"
see http://dev.mysql.com/doc/refman/5.1/en/regexp.html
However, take note that it will be slow and you should do what others posters suggested and store the clean value in a separate field.