Extracting first word of no fixed length from a string
Extracting first word of no fixed length from a string
(OP)
Greetings all!
I wonder if it is possible to extract a first word from a string? For example: "Steel Hardened Polished Blah Blah" would should return "String". The problem is that word can be different and it's length is not fixed. Otherwise I would use SUBSTRING function. Any ideas?
I wonder if it is possible to extract a first word from a string? For example: "Steel Hardened Polished Blah Blah" would should return "String". The problem is that word can be different and it's length is not fixed. Otherwise I would use SUBSTRING function. Any ideas?





RE: Extracting first word of no fixed length from a string
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: Extracting first word of no fixed length from a string
RE: Extracting first word of no fixed length from a string
blank_pos = fndstr('This is a long string',1,' ')
blank_pos would be set to 5
then use
short_string = substr ('This is a long string',1,blank_pos)
short_string would be set to 'This'
may need a -1 added to the blank_pos to get the 4 charcaters (blamk_pos-1)
"Wildfires are dangerous, hard to control, and economically catastrophic."
Ben Loosli
RE: Extracting first word of no fixed length from a string
RE: Extracting first word of no fixed length from a string
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: Extracting first word of no fixed length from a string
RE: Extracting first word of no fixed length from a string
CODE
The resulting value of m3 will be: "this".
www.nxjournaling.com
RE: Extracting first word of no fixed length from a string
Thank you very much! It works! Brilliant!
The problems is there is no documentation on splitstring function. At least I could not find it.
Also, if I need to reference second, third, etc member of list, how must I write it? Is there a documentation on this?
RE: Extracting first word of no fixed length from a string
In the example above, m2 is a list. You can use the list function length() to find out how many items are in the list and the nth() list function to return a specific item. Check out the list functions in the expression editor as there are other functions in there as well.
www.nxjournaling.com
RE: Extracting first word of no fixed length from a string
C:\Program Files\Siemens\NX 8.5\UGDOC\html_files\nx_api\en_US\graphics\fileLibrary\nx\fusion\
...if you just accepted the defaults when you installed NX using the installshield. Is you installed NX somewhere else then you'll have to edit the path above to match that location. Now when you do this you will get an explorer window with a list of .html files whose titles will be the only real hint that you'll have as to what they are used for. To see the details of a function just double-click the .html file of interest.
Anyway, good luck and have fun
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: Extracting first word of no fixed length from a string
So to access this patricular docs I need to have NX Open help option checked while installing the NX Help?
RE: Extracting first word of no fixed length from a string
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: Extracting first word of no fixed length from a string
Thank you! No problem with that, I can isntall the missing help components.
And a stupid question: how to measure the length of the string? Is there a function responsible for this?
RE: Extracting first word of no fixed length from a string
RE: Extracting first word of no fixed length from a string
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: Extracting first word of no fixed length from a string
One more question: how to measure the length of the string? Is there a function responsible for this?
For example: measuring 'steel' string to return number 5.
RE: Extracting first word of no fixed length from a string
RE: Extracting first word of no fixed length from a string
It seems to be working, thank you.
Do you have answers for my latter questions?
RE: Extracting first word of no fixed length from a string
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: Extracting first word of no fixed length from a string
RE: Extracting first word of no fixed length from a string
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: Extracting first word of no fixed length from a string
If that east coast software I use was 3/4 as robust as UG/NX, my life would be a lot easier!
"Wildfires are dangerous, hard to control, and economically catastrophic."
Ben Loosli