Notifications
Clear all

[Closed] find a string using a substring

Hi
So I`m reading from a text file that looks like this:
PartComponentData 0ef06d0bf3b52f4c58b19eea41864f05
$::ComponentData
$::GameObjectData
$::GameDataContainer
$::DataContainer
IsEventConnectionTarget 2
IsPropertyConnectionTarget 3
IndexInBlueprint -1
Transform::LinearTransform
[COLOR=Green] (Some lines down)
PartComponentData 944702cf40cf632485827734568c380b
$::ComponentData
$::GameObjectData
$::GameDataContainer
$::DataContainer
IsEventConnectionTarget 3
IsPropertyConnectionTarget 3
IndexInBlueprint -1[/COLOR]

Now I need to find all lines in the file that have substring “ComponentData” and return first part of the string, in these both cases “Part”(it does change to, “camera”, “object”, “bone”…) to an array.

skiptostring sfile “ComponentData” does jump to line ComponentData but “Part” bit is lost. So how do I read the first Characters “Part” of the string “PartComponentData”? Any suggestions guys?

thank you

2 Replies

You can use matchPattern or findString to locate ComponentData . MatchPattern is faster but findString will give the index of the first letter of the search string so it can be then used for the substring command to extract the part you need.

Example (untested)

file = “insertfilenamehere”
ofile = openfile file

while not eof ofile do
(
rl = readline file
index = findString rl “ComponentData”
if index != undefined do
(
part = subString rl 1 index
)
)

close ofile

1 Reply
(@dainiuxxx)
Joined: 10 months ago

Posts: 0

thanks bnvm,
It does not quite work as I want it to, but I`m using a “matchpattern()” and that works ok.
Thanks again for pointing me into the right direction. ;]