+14 votes
by (100 points)

I Have a table like below

 Property   Value

 Adapter    [00000007] Intel(R) 82567LM Gigabit Network Connection
 Adapter    [00000009] VMware Virtual Ethernet Adapter for VMnet1
 Adapter    [00000012] Dell Wireless 1397 WLAN Mini-Card

from above table i want to split values column string into two columns like below is:

String1        String2
[00000007]     Intel(R) 82567LM Gigabit Network Connection
[00000009]     VMware Virtual Ethernet Adapter for VMnet1

Any solution please.

12 Answers

+19 votes
by (100 points)
select 
  substring(Value,charindex('[',Value,1),charindex(']',value,charindex('[',Value,1)-1)) as String1
  ,ltrim(rtrim(substring(Value,charindex(']',value)+1,len(value)))) as String2
from Table1

SQL Fiddle

+13 votes
by (100 points)

As the question has changed this is no longer relevant but may prove useful to others...

This seems to work:

declare @value varchar(100) = '[00000007] Intel(R) 82567LM Gigabit Network Connection'

SELECT 
SUBSTRING(@value, 0, CHARINDEX(']', @value,0) + 1) firstPart,
LTRIM(RTRIM(SUBSTRING(@value, CHARINDEX(']', @value,0)+1, LEN(@value)))) secondPart
+10 votes
by (100 points)

If your case simple one will work:

select
    Property,
    substring(Value, 2, 8) as String1,
    -- or substring(Value, 1, 10) if you want [ and ]
    right(Value, len(Value) - 11) as String2
from Table1

sql fiddle demo

+5 votes
by (100 points)

This is a bit more generic version to support for any number of characters before the first space ( Fiddle demo ):

SELECT LEFT(@S, CHARINDEX(' ',@S)) String1,
       RIGHT (@S, LEN(@S) - CHARINDEX(' ',@S)) String2

Applying to your Table:

SELECT LEFT(Value, CHARINDEX(' ',Value)) String1,
       RIGHT (Value, LEN(Value) - CHARINDEX(' ',Value)) String2
FROM yourTable
0 votes
by (100 points)
function filterOnPlayerStatSummary(myObject, filter)
{
    var result = [];
    for(var i = 0; i < myObject.length; i++) 
    {
        if (myObject[i].playerStatSummary == filter)
        { 
            result.push(myObject[i]);
        }
    }

    return result;
}
0 votes
by (100 points)

The i that you are returning inside the inner function - is the i that was declared inside the for(var i=0...) therefor - it is the same i for all of the functions in result and by the time you are calling the functions its value is 10 (after the loop ends)

to accomplish what you wanted you should declare another variable inside the scope of the anonymous function

0 votes
by (100 points)

Make relinks your project because it tries to build all . The rule for all does not create any file named all . Instead it produces myexe . Next time you run make, it will see that there's no all , but there's a rule to build one, so it dutifully executes that rule which happens to link myexe every time you run make.

In order to fix your problem you need to change your makefile to look roughly like this:

all: myexe
    echo Build done

myexe: <myexe dependencies go here>
    $(CXX) $(CFLAGS) -o myexe $(wildcard *.o) $(LDFLAGS)
0 votes
by (100 points)

Bytecodes are the machine language of the Java virtual machine. When a JVM loads a class file, it gets one stream of bytecodes for each method in the class. The bytecodes streams are stored in the method area of the JVM. The bytecodes for a method are executed when that method is invoked during the course of running the program. They can be executed by intepretation, just-in-time compiling, or any other technique that was chosen by the designer of a particular JVM.

A method's bytecode stream is a sequence of instructions for the Java virtual machine. Each instruction consists of a one-byte opcode followed by zero or more operands. The opcode indicates the action to take. If more information is required before the JVM can take the action, that information is encoded into one or more operands that immediately follow the opcode.

Each type of opcode has a mnemonic. In the typical assembly language style, streams of Java bytecodes can be represented by their mnemonics followed by any operand values. For example, the following stream of bytecodes can be disassembled into mnemonics:

// Bytecode stream: 03 3b 84 00 01 1a 05 68 3b a7 ff f9
// Disassembly:
iconst_0 // 03
istore_0 // 3b
iinc 0, 1 // 84 00 01
iload_0 // 1a
iconst_2 // 05
imul // 68
istore_0 // 3b
goto -7 // a7 ff f9

The bytecode instruction set was designed to be compact. All instructions, except two that deal with table jumping, are aligned on byte boundaries. The total number of opcodes is small enough so that opcodes occupy only one byte. This helps minimize the size of class files that may be traveling across networks before being loaded by a JVM. It also helps keep the size of the JVM implementation small.

All computation in the JVM centers on the stack. Because the JVM has no registers for storing abitrary values, everything must be pushed onto the stack before it can be used in a calculation. Bytecode instructions therefore operate primarily on the stack. For example, in the above bytecode sequence a local variable is multiplied by two by first pushing the local variable onto the stack with the iload_0 instruction, then pushing two onto the stack with iconst_2. After both integers have been pushed onto the stack, the imul instruction effectively pops the two integers off the stack, multiplies them, and pushes the result back onto the stack. The result is popped off the top of the stack and stored back to the local variable by the istore_0 instruction. The JVM was designed as a stack-based machine rather than a register-based machine to facilitate efficient implementation on register-poor architectures such as the Intel 486.

0 votes
by (100 points)

There are a few entries at Embarcadero quality portal regarding your issue. Here is one .

It seems the error is confirmed for the original version " Delphi 10 Seattle " but fixed in update 1 " Delphi 10 Seattle UD1 ".

I tested the functionality successfully in " Delphi 10 Seattle UD1 " and " Delphi 10.1 Berlin ".

0 votes
by (100 points)

This is a feature of Scala collections (String in this case is treated as a collection of characters). The real explanation is quite complex, and involves understanding of typeclasses (I guess, this is why Haskell was mentioned in the comment), but the simple explanation is, well, not quite hard.

The point is, Scala collections library authors tried very hard to avoid code duplication. For example, the map function on String is actually defined here: scala.collection.TraversableLike#map . On the other hand, a naive approach to such task would make map return TraversableLike , not the original type the map was called on (it was the String ). That's why they've came up with an approach that allows to avoid both code duplication and unnecessary type casting or too general return type.

Basically, Scala collections methods like map produce the type that is as close to the type it was called at as possible. This is achieved using a typeclass called CanBuildFrom . The full signature of the map looks as follows:

def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That

There is a lot of explanations what is a typeclass and CanBuildFrom around. I'd suggest looking here first: http://docs.scala-lang.org/overviews/core/architecture-of-scala-collections.html#factoring-out-common-operations . Another good explanation is here: Scala 2.8 CanBuildFrom

Related questions

+2 votes
11 answers
+8 votes
8 answers
+12 votes
11 answers
+14 votes
7 answers
...