[root@jiaoyou ~]# test 1 = 1 -a 0 = 1
[root@jiaoyou ~]# if [1 = 1 -a 0 = 1]then echo 1;else echo 2;fi
-bash: syntax error near unexpected token `else'
Why test doesn't give any output and the if statement fails?
Can someone point out what's wrong here?
input:
string1="this is a joke.this is not life.";
string2="this is not a joke. this is life.";
by comparing string1&string 2 we found
output:
pos8 deleted 4 chars " not"
pos28 inserted 4 chars " not"
Let's say I have a list of elements
@list=(1,2,3);
#desired output
1,2,3
And I want to print them as comma seperated values. And most importantly, I do not want the last element to have a comma after it.
What is the cleanest way to do this in Perl?
I had a regex that replaced all URLs from a given string:
my_string = "www.example.com test www.mysite.com"
my_string.gsub!(/[a-zA-Z0-9\-\.]+\.(com|net|de|org|uk|biz|info|co.uk|es|de)(\/\S*)?/i,'(site hidden)')
As a result of the above I get: "(site hidden) test (site hidden)"
How could I change the regex to not replace www.mysite.com ???
It means that the replace should output "(site hidden) test www.mysite.com"
Thanks !
I need to design a function to return -ve numbers unchanged but should add a + sign at the start of the number if its alreay no present.
Example:
Input Output
----------------
+1 +1
1 +1
-1 -1
It will get only numeric input.
function formatNum($num)
{
# something here..perhaps a regex?
}
This function is going to be called several times in echo/print so the quicker the better.
Can someone suggest an algorithm that finds all Pythagorean triplets among numbers in a given array? If it's possible, please, suggest an algorithm faster than O(n2).
Pythagorean triplet is a set {a,b,c} such that a2 = b2 + c2. Example: for array [9, 2, 3, 4, 8, 5, 6, 10] the output of the algorithm should be {3, 4, 5} and {6, 8, 10}.
I have a Hashmap object that i am getting on a jsp page.
HashMap<Integer,Gift_product> gift_hm = new HashMap<Integer,Gift_product>();
gift_hm.put(17,new Gift_product("doll",67));
now i need to iterate this and display content on jsp.
as Gift_product class contains two fields name and price
jsp output should be
serial no. product name price
17 Doll 67
How can i achieve it..
Is there a way for a property to access its own name and type at runtime using reflection? I want to access this info without hard coding the name or index of the property in the class.
Simple Example Code:
Private ReadOnly Property MyProperyName() As String
Get
Console.WriteLine((Get Current Property Info).Type.ToString)
Console.WriteLine((Get Current Property Info).Name)
Return ""
End Get
End Property
Expected output:
System.String
MyPropertyName
When looking up messages in a sasl log using rb:list() or rb:show(), rb seems to dump the output in the console and return 'ok'; is there any way to configure rb to get it to return the actual log message ?
Thanks
I'm currently using regular expressions to search through RSS feeds to find if certain words and phrases are mentioned, and would then like to extract the text on either side of the match as well. For example:
String = "This is an example sentence, it is for demonstration only"
re.search("is", String)
I'd like to know where the is was found so that I can extract and output something like this:
1 match found: "This is an example sentence"
I know that it would be easy to do with splits, but I'd need to know what the index of first character of the match was in the string, which I don't know how to find
At random this output it occurring at the top of the page. Site is installed on a lot of servers issue only happens on one server.
HTTP/1.1 200 OK Date: Mon, 24 May 2010 04:18:30 GMT Server:
Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727
Cache-Control: private Content-Type: text/html; charset=utf-8
Content-Length: 39611
Does anyone know how to pass Content/ContentPlaceholder information from a page, up through it's master page, to the parent master page?
Like this example, but with content defined in ChildFile (the page), being output in ParentMaster (q matster page one level higher in the nesting).
Hi all,
I am new to this kind of application and looking for some sample code how to connect to remote server using SSH , execute commands and get output back using java as programming language.
Thanks in advance.....
Regards,
Devayani
The first print shows the member value to be false, and the other two prints show it as true. Why does the first output differ from the last two?
#include
#include
using namespace std;
class MyClass
{
public:
bool value;
bool stuff;
};
class Container
{
public:
vector my_classes;
Container()
{
MyClass c;
cout
I'm trying to match rc-update -s output in python.
m = re.match(r"^\s*(\w+)\s*\|{\s*(\w+)\s*}*$", " network | level1 level2 leveln ")
but m is always None
the hard part for me is getting the regex to match the n levels. I thought that using {}* would match the n levels, but as soon as I add the {} nothing matches.
thanks.
HI I am a new java programmer (very new).
What I want to do/test is (not sure if its recommendable or doable?), we know that
System.out.println("Message");
will output the "Message" in command prompt. Is it possible to display the current time, without having to repeatly use the system.out.println()?
Name, like instead of displaying:
10:00:01
10:00:02
10:00:03
I wand to have liek this:
10:00:0X where X will continue counting
right, so i just tossed this super simple code example into a Flash CS4 IDE frame script, but it doesn't output anything in the console. i'm simply rolling over my mouse over the window, not clicking anything, and nothing is happening. wtf?!
stage.addEventListener(Event.MOUSE_LEAVE, traceMouse);
function traceMouse(Evt:Event):void
{
trace("Mouse Left Stage");
}
In Java how can I take the data of my file on my display screen?
I want to use data in my file and also want that data to be displayed on my output screen when I execute my program. Can any body please help by providing me such example in Java language. Thank you!
Hi all,
I need to convert the system datetime to timestamp in script task SSIS.
input date format: 29/05/2010 2:36 AM
output format: 29-15-2010 14:36:00
thanks
prav
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\program\sanweetha\quotation.php:280) in C:\xampp\htdocs\program\sanweetha\php\captcha demo\captcha_demo.php on line 1
What would be matlab's equivalent of
write(1,'("Speed, resistance, power",3f8.2)')(a(i),i=1,3)
I've tried
a = [10. 20. 200.]
fprintf(unit1,'a = 3%8.1e',a)
but I'm still having trouble with it (the whole matlab output formatting thing).
Edit for Kenny: for the values of a as given above, it would give (in a new row):
Speed, resistance, power 10.00 20.00 200.00
I have a function in win32 dll with signature as:
void func1(int a, char*** outData)
int a -- input parameter
char*** outData -- output parameter - pointer to array of char strings
Any idea how to access this in C# using dll import & what should be the signature.
I'm trying to write a store procedure that can take some input parameters (obviously), run multiple queries against those, taking the output from those and doing calculations, and from those calculations and the original queries, outputting a formatted text string like:
Number of Rows for max(Z) matching condition x and y of total rows matching x (x&y/x*100).
To explain the max(Z) bit, this will be the username field, it won't matter which actual entry is picked, because the where clause will filter the results by user id, is there a saner way to do this?